/
githubmirror
/
materialize
Обзор
Документация
Войти
/
githubmirror
/
materialize
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
v0.100.0
test/html/scrollfire.html
99 строк
3 KB
Chang Alan
generalized throttle and added to scrollFire
21 ноя 2016, 03:34
21 ноя 2016, 03:34
0257ec7
Код
Авторство
О чём код?
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no"/> <title>Documentation - Materialize</title> <!-- CSS --> <link href="../../../bin/materialize.css" type="text/css" rel="stylesheet" media="screen,projection"/> <style> body, html, .section { height: 100%; } .wrapper { height: 100%; width: 100%; position: relative; overflow: hidden; } .table-of-contents li a { color: #fff; } .box { width: 50%; height: 50%; transform: translateX(-100%); background-color: #444; transition: transform .3s; } #green .box, #red .box { position: absolute; right: 0; transform: translateX(100%); } .scrolled .box, #green.scrolled .box, #red.scrolled .box { transform: translateX(0); } </style> </head> <body> <div id="blue" class="section scrollspy blue"> <div class="wrapper"> <div class="box"></div> </div> </div> <div id="green" class="section scrollspy green"> <div class="wrapper"> <div class="box"></div> </div> </div> <div id="yellow" class="section scrollspy yellow"> <div class="wrapper"> <div class="box"></div> </div> </div> <div id="red" class="section scrollSpy red"> <div class="wrapper"> <div class="box"></div> </div> </div> <div class="stats" style="position: fixed; top: 50%; left: 50%; width: 100px; margin-left: -50px;"> <strong>scrollTop: </strong><span id="scrollTop">0</span> </div> <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script> <script src="../../../bin/materialize.js"></script> <script type="text/javascript"> $( document ).ready(function() { var options = [ {selector: '#blue', offset: 50, callback: function(el) { $(el).addClass('scrolled'); } }, {selector: '#green', offset: 50, callback: function(el) { $(el).addClass('scrolled'); } }, {selector: '#yellow', offset: 50, callback: function(el) { $(el).addClass('scrolled'); } }, {selector: '#red', offset: 50, callback: function(el) { $(el).addClass('scrolled'); } }, ]; Materialize.scrollFire(options); $(window).on('scroll', function() { $('#scrollTop').text($(window).scrollTop()); }); }); </script> </body> </html>