Nuno Monteiro Posted January 31, 2017 at 05:17 PM Report Share #602236 Posted January 31, 2017 at 05:17 PM Boas. É o primeiro tópico que crio. Estou a desenvolver o meu primeiro projecto web. É uma webpage dinâmica e responsiva em que uso jQuery e Bootstrap, e alguns efeitos parallax scrolling. Tenho uma <section> com background fixo que contem um título (<h2>) e texto com vários paragrafos (<p>). O que pretendo é que estes não estejam visíveis até que o utilizador faça scroll para essa secção. A animação deve ter um fade-in e mover-se de baixo para cima. Encontrei um JSFiddle que executa o fade-in: https://jsfiddle.net/tcloninger/e5qaD/ Tentei implementar no meu projecto, mas sem sucesso. O que poderei estar a fazer de errado? Obrigado. Aqui deixo o meu HTML: <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content=""> <meta name="author" content=""> <title>xxxxxxxx</title> <!-- Bootstrap Core CSS --> <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"> <!-- Custom Fonts --> <link href="vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Montserrat:400,700" rel="stylesheet" type="text/css"> <!-- Theme CSS --> <link href="css/grayscale.css" rel="stylesheet"> </head> <body id="page-top" data-spy="scroll" data-target=".navbar-fixed-top"> <!-- Navigation --> <nav class="navbar navbar-custom navbar-fixed-top" role="navigation"> <div class="container"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main-collapse"> Menu <i class="fa fa-bars"></i> </button> <div class="navbar-brand page-scroll"> <a href="#page-top"> <span style="float:left;display: block;"> <img id="logo" src="img/small_140x146_EBP_logo.png"/> </span> <span id="brandname" style="float:left; display: block;"> <span>xxxxxx <span class="light">xxxxxxx</span> </span> <span class="clear-fix"></span> </a> </div> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse navbar-right navbar-main-collapse"> <ul class="nav navbar-nav"> <!-- Hidden li included to remove active class from project link when scrolled up past project section --> <li class="hidden"> <a href="#page-top"></a> </li> <li> <a class="page-scroll hidden-sm" href="#project">Project</a> </li> <li> <a class="page-scroll" href="#news">News</a> </li> <li> <a class="page-scroll" href="#download">Download</a> </li> <li> <a class="page-scroll" href="#contact">Contact</a> </li> </ul> </div> <!-- /.navbar-collapse --> </div> <!-- /.container --> </nav> <!-- Intro Header --> <!-- background video whit letters on top --> <!-- responsive embed video --> <div class="embed-responsive embed-responsive-16by9"> <!-- header class with intro from bootstrap --> <header class="intro "> <!-- video tag, autoplayed with no loop and no sound --> <video preload="true" autoplay="autoplay" loop="loop" volume="0" poster="sources/videos/website_intro.png" style="opacity:0.7"> <source src="img/intro_web_temp.mp4" type="video/mp4"> <source src="img/intro_website.ogv" type="video/ogg"> <source src="img/intro_website.webm" type="video/webm"> </video> <!-- end of video --> <!-- here goes whatever you want to put on top of video --> <!-- container of text --> <div class="intro-text-container"> <!-- container of row from bootstrap --> <div class="row" style="margin-top: 42%"> <!-- another class of bootstrap for responsive text --> <div class="col-md-8 col-md-offset-2"> <a href="#project" class="btn btn-circle page-scroll"> <i class="fa fa-angle-double-down animated"></i> </a> </div> <!-- end of bootstrap's responsive text div --> </div> <!-- end of row --> </div> <!-- end of container of text --> </header> <!-- end of header --> </div> <!-- end of responsive embed video --> <!-- project Section --> <section id="project" class="container content-section text-center"> <div class="row"> <div class="col-lg-8 col-lg-offset-2"> <h2 class="hideme">Our Project</h2> <p class="hideme">xxxxxxxxxxxxxx<span class="highlight">best</span>xxxxxxxxxxx</p> <p class="hideme">xxxxxxxxxxx <span class="highlight">veterans</span> or <span class="highlight">xxxxxxxxxx</span> athletes.</p> <p class="hideme"><span class="highlight">xxxxxx</span>, <span class="highlight">xxxxxxxxxx</span>, xxxxxx <span class="highlight">xxxxxxxxxx</span> xxxxxxxxxxxx</p> <p class="hideme">xxxxxxxxxx<span class="highlight">xxxxxx</span>, <span class="highlight">skills</span>, <span class="highlight">xxxxxxxxx</span>xxxxxxxxx<span class="highlight">xxxxxxxxxxxxxxx <span class="highlight">better</span>.</p> </div> </div> </section> <section id="news"> <div id="carousel-example-generic" class="carousel carousel-fullscreen slide carousel-fade" data-ride="carousel" data-interval="4000" data-pause="null"> <!-- Indicators --> <ol class="carousel-indicators"> <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> <li data-target="#carousel-example-generic" data-slide-to="1"></li> <li data-target="#carousel-example-generic" data-slide-to="2"></li> </ol> <!-- Wrapper for slides --> <div class="carousel-inner" role="listbox"> <div class="item active" style="background-image: url('img/nuno_fire_effect.png');"> <div class="overlay"></div> <div class="carousel-caption"> <h1 class="super-heading">Bootstrap Carousel Guide</h1> <p class="super-paragraph">This is a demo for the Bootstrap Carousel Guide by <a href="https://bootstrapious.com">Bootstrapious.com</a>.</p> </div> </div> <div class="item" style="background-image: url('img/dora_bg_in-game_benfica_sandstorm.png');"> <div class="overlay"></div> <div class="carousel-caption"> <h1 class="super-heading">Lorem ipsum dolor color</h1> <p class="super-paragraph">This is a demo for the Bootstrap Carousel Guide.</p> </div> </div> <div class="item" style="background-image: url('img/arnette_bg_sandstorm.png');"> <div class="overlay"></div> <div class="carousel-caption"> <h1 class="super-heading">Lorem ipsum dolor color</h1> <p class="super-paragraph">This is a demo for the Bootstrap Carousel Guide.</p> </div> </div> <!-- Controls --> <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> <span class="sr-only">Previous</span> </a> <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> <span class="sr-only">Next</span> </a> </div> </section> <!-- Download Section --> <section id="download" class="content-section text-center"> <div class="download-section"> <div class="container"> <div class="col-lg-8 col-lg-offset-2"> <h2>Download Grayscale</h2> <p>You can download Grayscale for free on the preview page at Start Bootstrap.</p> <a href="http://startbootstrap.com/template-overviews/grayscale/" class="btn btn-default btn-lg">Visit Download Page</a> </div> </div> </div> </section> <!-- Contact Section --> <section id="contact" class="container content-section text-center"> <div class="row"> <div class="col-lg-8 col-lg-offset-2"> <h2>Contact Start Bootstrap</h2> <p>Feel free to email us to provide some feedback on our templates, give us suggestions for new templates and themes, or to just say hello!</p> <p><a href="mailto:feedback@startbootstrap.com">feedback@startbootstrap.com</a> </p> <ul class="list-inline banner-social-buttons"> <li> <a href="https://twitter.com/SBootstrap" class="btn btn-default btn-lg"><i class="fa fa-twitter fa-fw"></i> <span class="network-name">Twitter</span></a> </li> <li> <a href="https://github.com/IronSummitMedia/startbootstrap" class="btn btn-default btn-lg"><i class="fa fa-github fa-fw"></i> <span class="network-name">Github</span></a> </li> <li> <a href="https://plus.google.com/+Startbootstrap/posts" class="btn btn-default btn-lg"><i class="fa fa-google-plus fa-fw"></i> <span class="network-name">Google+</span></a> </li> </ul> </div> </div> </section> <!-- Map Section --> <div id="map"></div> <!-- Footer --> <footer> <div class="container text-center"> <p>Copyright © Your Website 2016</p> </div> </footer> <!-- jQuery --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>"></script> <!-- Bootstrap Core JavaScript --> <script src="vendor/bootstrap/js/bootstrap.min.js"></script> <!-- Plugin JavaScript --> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js"></script> <!-- Google Maps API Key - Use your own API key to enable the map feature. More information on the Google Maps API can be found at https://developers.google.com/maps/ --> <script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCRngKslUGJTlibkQ3FkfTxj3Xss1UlZDA&sensor=false"></script> <!-- Theme JavaScript --> <script src="js/grayscale.min.js"></script> </body> </html> Aqui o CSS: body { width: 100%; height: 100%; font-family: "Lora", "Helvetica Neue", Helvetica, Arial, sans-serif; color: white; background-color: black; } html { width: 100%; height: 100%; } h1, h2, h3, h4, h5, h6 { margin: 0 0 35px; text-transform: uppercase; font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 700; letter-spacing: 1px; } p { margin: 0 0 25px; font-size: 18px; line-height: 1.5; } @media (min-width: 768px) { p { margin: 0 0 35px; font-size: 20px; line-height: 1.6; } } a { color: #42DCA3; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } a:hover, a:focus { text-decoration: none; color: #1d9b6c; } .light { font-weight: 400; } .navbar-custom { margin-bottom: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.3); text-transform: uppercase; font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif; background-color: #111111; } .navbar-custom .navbar-toggle { color: white; background-color: rgba(255, 255, 255, 0.2); font-size: 12px; } .navbar-custom .navbar-toggle:focus, .navbar-custom .navbar-toggle:active { outline: none; } .navbar-custom .navbar-brand { font-weight: 700; } .navbar-custom .navbar-brand:focus { outline: none; } .navbar-custom a { color: white; } .navbar-custom .nav li a { -webkit-transition: background 0.3s ease-in-out; -moz-transition: background 0.3s ease-in-out; transition: background 0.3s ease-in-out; } .navbar-custom .nav li a:hover { color: rgba(255, 255, 255, 0.8); outline: none; background-color: transparent; } .navbar-custom .nav li a:focus, .navbar-custom .nav li a:active { outline: none; background-color: transparent; } .navbar-custom .nav li.active { outline: none; } .navbar-custom .nav li.active a { background-color: rgba(255, 255, 255, 0.3); } .navbar-fixed-top a{ margin-top: 10px; } @media (min-width: 768px) { .navbar-custom { padding: 20px 0; border-bottom: none; letter-spacing: 1px; background: transparent; -webkit-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out; -moz-transition: background 0.5s ease-in-out, padding 0.5s ease-in-out; transition: background 0.5s ease-in-out, padding 0.5s ease-in-out; } .navbar-custom.top-nav-collapse { padding: 0; background: black; border-bottom: 1px solid rgba(255, 255, 255, 0.3); } } .intro { display: table; width: 100%; height: auto; padding: 100px 0; text-align: center; color: white; } .intro .intro-body { display: table-cell; vertical-align: middle; } .intro .intro-body .brand-heading { font-size: 40px; } .intro .intro-body .intro-text { font-size: 18px; } @media (min-width: 768px) { .intro { height: 100%; padding: 0; } .intro .intro-body .brand-heading { font-size: 100px; } .intro .intro-body .intro-text { font-size: 26px; } } .btn-circle { width: 40px; height: 40px; margin-top: -5%; padding: 0px 0px; border: 2px solid white; border-radius: 100% !important; font-size: 30px; color: white; background: transparent; -webkit-transition: background 0.3s ease-in-out; -moz-transition: background 0.3s ease-in-out; transition: background 0.3s ease-in-out; } .btn-circle:hover, .btn-circle:focus { outline: none; color: white; background: rgba(255, 255, 255, 0.1); } .btn-circle i.animated { -webkit-transition-property: -webkit-transform; -webkit-transition-duration: 1s; -moz-transition-property: -moz-transform; -moz-transition-duration: 1s; } .btn-circle:hover i.animated { -webkit-animation-name: pulse; -moz-animation-name: pulse; -webkit-animation-duration: 1.5s; -moz-animation-duration: 1.5s; -webkit-animation-iteration-count: infinite; -moz-animation-iteration-count: infinite; -webkit-animation-timing-function: linear; -moz-animation-timing-function: linear; } @-webkit-keyframes pulse { 0% { -webkit-transform: scale(1); transform: scale(1); } 50% { -webkit-transform: scale(1.2); transform: scale(1.2); } 100% { -webkit-transform: scale(1); transform: scale(1); } } @-moz-keyframes pulse { 0% { -moz-transform: scale(1); transform: scale(1); } 50% { -moz-transform: scale(1.2); transform: scale(1.2); } 100% { -moz-transform: scale(1); transform: scale(1); } } .content-section { padding-top: 100px; padding-bottom: 100px; } .download-section { width: 100%; padding: 50px 0; color: white; background: url(../img/downloads-bg.jpg) no-repeat center center scroll; background-color: black; -webkit-background-size: cover; -moz-background-size: cover; background-size: cover; -o-background-size: cover; } #map { width: 100%; height: 200px; margin-top: 100px; } @media (min-width: 767px) { .content-section { padding-top: 250px; } .download-section { padding: 100px 0; } #map { height: 400px; margin-top: 250px; } } .btn { text-transform: uppercase; font-family: "Montserrat", "Helvetica Neue", Helvetica, Arial, sans-serif; font-weight: 400; -webkit-transition: all 0.3s ease-in-out; -moz-transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out; border-radius: 0; } .btn-default { border: 1px solid #42DCA3; color: #42DCA3; background-color: transparent; } .btn-default:hover, .btn-default:focus { border: 1px solid #42DCA3; outline: none; color: black; background-color: #42DCA3; } ul.banner-social-buttons { margin-top: 0; } @media (max-width: 1199px) { ul.banner-social-buttons { margin-top: 15px; } } @media (max-width: 767px) { ul.banner-social-buttons li { display: block; margin-bottom: 20px; padding: 0; } ul.banner-social-buttons li:last-child { margin-bottom: 0; } } footer { padding: 50px 0; } footer p { margin: 0; } ::-moz-selection { text-shadow: none; background: #fcfcfc; background: rgba(255, 255, 255, 0.2); } ::selection { text-shadow: none; background: #fcfcfc; background: rgba(255, 255, 255, 0.2); } img::selection { background: transparent; } img::-moz-selection { background: transparent; } body { webkit-tap-highlight-color: rgba(255, 255, 255, 0.2); } .embed-responsive { height: 60%; width: 100%; } .embed-responsive-16by9 { top:-100px; } video { position: absolute; z-index: -1000; opacity: 0.8; width: 100%; overflow: hidden; } .clear-fix { clear: both !important; display: block !important; font-size: 0 !important; line-height: 0 !important; border: none !important; padding: 0 !important; margin: 0 !important; list-style: none !important; } #logo { height: 38px; width: 38px; margin-top:-17%; margin-left:-3%; margin-right:16%; transition: all 0.3s ease-in-out; } #brandname { margin-top: 2%; font-size: 20px; } .nav.navbar-nav li { margin-top: -1%; } .content-section { margin-top: -100px; } @media (min-width:1119px) { .embed-responsive { height: 100%; } .content-section { padding-top: 100px; margin-top: 0px; padding-bottom: 100px; } } @media (min-width:768px) { .navbar-custom.navbar-fixed-top.top-nav-collapse{ background-color: #111111; } .navbar-custom.navbar-fixed-top.top-nav-collapse #logo { height: 38px; width: 38px; margin-top:-17%; margin-left:-3%; margin-right:16%; transition: all 0.3s ease-in-out; } #logo { height: 82px; width: 80px; margin-top: -35%; margin-left: -20%; margin-right: 15%; transition: all 0.3s ease-in-out; } .embed-responsive { height: 85%; } .content-section { padding-top: 100px; margin-top: 100px; padding-bottom: 100px; } #download { padding-top: 0px; margin-top: 0px; } .btn-circle { width: 70px; height: 70px; margin-top: 15px; padding: 7px 16px; border: 2px solid white; border-radius: 100% !important; font-size: 40px; color: white; background: transparent; -webkit-transition: background 0.3s ease-in-out; -moz-transition: background 0.3s ease-in-out; transition: background 0.3s ease-in-out; } } .highlight { color: #42DCA3; -webkit-transition: all 0.2s ease-in-out; -moz-transition: all 0.2s ease-in-out; transition: all 0.2s ease-in-out; } #project { background-image: url("../img/elite_logo_small.png"); background-attachment: fixed; background-position: center; background-repeat: no-repeat; background-size: cover; } /* carousel fullscreen */ .carousel-fullscreen .carousel-inner .item { height: 100vh; min-height: 600px; background-position: center center; background-repeat: no-repeat; background-size: cover; } /* carousel fullscreen - vertically centered caption*/ .carousel-fullscreen .carousel-caption { top: 50%; bottom: auto; -webkit-transform: translate(0, -50%); -ms-transform: translate(0, -50%); transform: translate(0, -50%); } .carousel-fade .carousel-inner .item { -webkit-transition-property: opacity; transition-property: opacity; } .carousel-fade .carousel-inner .item, .carousel-fade .carousel-inner .active.left, .carousel-fade .carousel-inner .active.right { opacity: 0; } .carousel-fade .carousel-inner .active, .carousel-fade .carousel-inner .next.left, .carousel-fade .carousel-inner .prev.right { opacity: 1; } .carousel-fade .carousel-inner .next, .carousel-fade .carousel-inner .prev, .carousel-fade .carousel-inner .active.left, .carousel-fade .carousel-inner .active.right { left: 0; -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); } .carousel-fade .carousel-control { z-index: 2; } .overlay { position: absolute; width: 100%; height: 100%; background: #000; opacity: 0.3; transition: all 0.2s ease-out; } /* controls hidden except on hover */ .carousel .carousel-control { visibility: hidden; } .carousel:hover .carousel-control { visibility: visible; } .hideme { opacity:0; } Aqui o Javascript: // jQuery to collapse the navbar on scroll function collapseNavbar() { if ($(".navbar").offset().top > 50) { $(".navbar-fixed-top").addClass("top-nav-collapse"); } else { $(".navbar-fixed-top").removeClass("top-nav-collapse"); } } $(document).ready(function(){ $(window).scroll(function(){ collapseNavbar(); /* Check the location of each desired element */ $('.hideme').each( function(i){ var bottom_of_object = $(this).offset().top + $(this).outerHeight(); var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( bottom_of_window > bottom_of_object ){ $(this).animate({'opacity':'1'},500); } }); }); }); // jQuery for page scrolling feature - requires jQuery Easing plugin $(function() { $('a.page-scroll').bind('click', function(event) { var $anchor = $(this); $('html, body').stop().animate({ scrollTop: $($anchor.attr('href')).offset().top }, 1500, 'easeInOutExpo'); event.preventDefault(); }); }); // Closes the Responsive Menu on Menu Item Click $('.navbar-collapse ul li a').click(function() { $(this).closest('.collapse').collapse('toggle'); }); $('#carousel-example-generic').carousel({ interval: 3000, pause: null }) // Google Maps Scripts var map = null; // When the window has finished loading create our google map below google.maps.event.addDomListener(window, 'load', init); google.maps.event.addDomListener(window, 'resize', function() { map.setCenter(new google.maps.LatLng(40.6700, -73.9400)); }); function init() { // Basic options for a simple Google Map // For more options see: https://developers.google.com/maps/documentation/javascript/reference#MapOptions var mapOptions = { // How zoomed in you want the map to start at (always required) zoom: 15, // The latitude and longitude to center the map (always required) center: new google.maps.LatLng(40.6700, -73.9400), // New York // Disables the default Google Maps UI components disableDefaultUI: true, scrollwheel: false, draggable: false, // How you would like to style the map. // This is where you would paste any style found on Snazzy Maps. styles: [{ "featureType": "water", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 17 }] }, { "featureType": "landscape", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 20 }] }, { "featureType": "road.highway", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 17 }] }, { "featureType": "road.highway", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 29 }, { "weight": 0.2 }] }, { "featureType": "road.arterial", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 18 }] }, { "featureType": "road.local", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 16 }] }, { "featureType": "poi", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 21 }] }, { "elementType": "labels.text.stroke", "stylers": [{ "visibility": "on" }, { "color": "#000000" }, { "lightness": 16 }] }, { "elementType": "labels.text.fill", "stylers": [{ "saturation": 36 }, { "color": "#000000" }, { "lightness": 40 }] }, { "elementType": "labels.icon", "stylers": [{ "visibility": "off" }] }, { "featureType": "transit", "elementType": "geometry", "stylers": [{ "color": "#000000" }, { "lightness": 19 }] }, { "featureType": "administrative", "elementType": "geometry.fill", "stylers": [{ "color": "#000000" }, { "lightness": 20 }] }, { "featureType": "administrative", "elementType": "geometry.stroke", "stylers": [{ "color": "#000000" }, { "lightness": 17 }, { "weight": 1.2 }] }] }; // Get the HTML DOM element that will contain your map // We are using a div with id="map" seen below in the <body> var mapElement = document.getElementById('map'); // Create the Google Map using out element and options defined above map = new google.maps.Map(mapElement, mapOptions); // Custom Map Marker Icon - Customize the map-marker.png file to customize your icon var image = 'img/map-marker.png'; var myLatLng = new google.maps.LatLng(40.6700, -73.9400); var beachMarker = new google.maps.Marker({ position: myLatLng, map: map, icon: image }); } Link to comment Share on other sites More sharing options...
JakeBass Posted January 31, 2017 at 05:39 PM Report Share #602237 Posted January 31, 2017 at 05:39 PM a página tem algum elemento com a classe ".navbar"? o código do fade in funciona se retirar a parte da navbar. $(document).ready(function() { /* Every time the window is scrolled ... */ $(window).scroll( function(){ /* Check the location of each desired element */ $('.hideme').each( function(i){ var bottom_of_object = $(this).offset().top + $(this).outerHeight(); var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( bottom_of_window > bottom_of_object ){ $(this).animate({'opacity':'1'},500); } }); }); }); Link to comment Share on other sites More sharing options...
Nuno Monteiro Posted January 31, 2017 at 05:42 PM Author Report Share #602238 Posted January 31, 2017 at 05:42 PM (edited) Sim, tem.... eu não incluí o codigo todo de html para não ficar um post demasiado longo. Se for preferível posso colocar na integra, quer o html, quer css quer javascript. Edited January 31, 2017 at 05:43 PM by Nuno Monteiro Link to comment Share on other sites More sharing options...
JakeBass Posted January 31, 2017 at 07:09 PM Report Share #602241 Posted January 31, 2017 at 07:09 PM para além disso há um bug nesta linha: $(document).ready(collapseNavbar, function() { o "ready" só corre uma função por isso teria de ficar assim: $(document).ready(function() { collapseNavbar(); Link to comment Share on other sites More sharing options...
Nuno Monteiro Posted January 31, 2017 at 07:09 PM Author Report Share #602242 Posted January 31, 2017 at 07:09 PM Refactored javascript: $(document).ready(function(){ $(window).scroll(function(){ // jQuery to collapse the navbar on scroll collapseNavbar(); /* Check the location of each desired element */ $('.hideme').each( function(i){ var bottom_of_object = $(this).offset().top + $(this).outerHeight(); var bottom_of_window = $(window).scrollTop() + $(window).height(); /* If the object is completely visible in the window, fade it it */ if( bottom_of_window > bottom_of_object ){ $(this).animate({'opacity':'1'},500); } }); }); }); Link to comment Share on other sites More sharing options...
Nuno Monteiro Posted January 31, 2017 at 07:16 PM Author Report Share #602243 Posted January 31, 2017 at 07:16 PM sketxz, vou editar o post original com o html, css e javascript completo. Estou já à algumas horas sem conseguir encontrar o erro, porque depois de alterar o bug, continua a não acontecer nada. Apenas esconde o <h2> e os <p>. Obrigado, pela ajuda. Link to comment Share on other sites More sharing options...
JakeBass Posted February 1, 2017 at 09:45 AM Report Share #602253 Posted February 1, 2017 at 09:45 AM aqui está a funcionar. O texto faz fade-in. Aparece-te algum erro na consola? 1 Report Link to comment Share on other sites More sharing options...
Nuno Monteiro Posted February 1, 2017 at 09:57 AM Author Report Share #602254 Posted February 1, 2017 at 09:57 AM Obrigado, sketxz. Foi um erro de principiante!! Estava a usar a versão minificada do js... bah. Obrigado, ao Happyhippyhippo por me ter ajudado a perceber o erro e ter dispensado algum tempo a mostrar-me como desenvolver através do gulp dev... Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now