¼ò½é
ºÍ WOW.js Ò»Ñù£¬scrollReveal.js Ò²ÊÇÒ»¿îÒ³Ãæ¹ö
¶¯ÏÔʾ¶¯»µÄ JavaScript£¬ÄÜÈÃÒ³Ãæ¸ü¼ÓÓÐȤ£¬¸üÎüÒýÓû§ÑÛÇò¡£²»Í¬µÄÊÇ WOW.js µÄ¶¯»Ö»²¥·ÅÒ»´Î£¬¶ø scrollReveal.js µÄ¶¯»¿ÉÒÔ²¥·ÅÒ»´Î»òÎÞÏ޴Σ»WOW.js ÒÀÀµ animate.css£¬¶ø scrollReveal.js ²»ÒÀÀµÆäËûÈκÎÎļþ¡£
ËäÈ» scrollReveal.js ²»ÒÀÀµ animate.css£¬µ«ËüµÄ¶¯»Ò²ÊÇÓà CSS3 ´´½¨µÄ£¬ËùÒÔËü²»Ö§³Ö IE10 ÒÔϵÄä¯ÀÀÆ÷¡£
ä¯ÀÀÆ÷¼æÈÝ
IE10+ ✔ | Chrome ✔ | Firefox ✔ | Opera ✔ | Safari ✔ |
IE6¡¢IE7 µÈÀϾÉä¯ÀÀÆ÷²»Ö§³Ö CSS3 ¶¯»£¬ËùÒÔûÓÐЧ¹û£¬²¢ÇÒÒòΪ²»Ö§³ÖһЩÊôÐÔ»ò·½·¨»á±¨´í¡£ÎªÁË´ïµ½¸üºÃµÄ¼æÈÝ£¬×îºÃ¼ÓÒ»¸öä¯ÀÀÆ÷¼°°æ±¾Åжϡ£
»ù±¾·½·¨
1¡¢ÒýÈëÎļþ
<script src="js/scrollReveal.js"></script>
2¡¢HTML
<div data-scroll-reveal>dowebok.com</div>
±ØÐë¸øÔªËؼÓÉÏ data-scroll-reveal ÊôÐÔ£¬¼ÓÉÏÖ®ºó»áÖ´ÐÐĬÈϵĶ¯»Ð§¹û£¬ÄãÒ²¿ÉÒÔ×Ô¶¨Òå¸ÄÊôÐÔÒÔÏÔʾ²»Í¬µÄ¶¯»Ð§¹û£¬È磺
<div data-scroll-reveal="enter left and move 50px over 1.33s">dowebok.com</div> <div data-scroll-reveal="enter from the bottom after 1s">Hello world!</div> <div data-scroll-reveal="wait 2.5s and then ease-in-out 100px">iPhone 6</div>
3¡¢JavaScript
window.scrollReveal = new scrollReveal(); //»òÕߣ¬elem Ϊ¶¯»ÔªËصÄÈκ춱ðµÄ¸¸ÔªËØ window.scrollReveal2 = new scrollReveal({elem: document.getElementById('srcontainer')});
data-scroll-revealÊôÐÔ
ÉÏÃæ˵ÁË¿ÉÒÔ×Ô¶¨Òå data-scroll-reveal ÊôÐÔ£¬ÏÂÃæÀ´¿´¿´¸ÃÊôÐԵĹؼü´ÊºÍÖµ£¨¿ÉÑ¡£©¡£
enter
- ˵Ã÷: ¶¯»Æðʼ·½Ïò
- Öµ: top | right | bottom | left
move
- ˵Ã÷: ¶¯»Ö´ÐоàÀë
- Öµ: Êý×Ö£¬ÒÔ px Ϊµ¥Î»
over
- ˵Ã÷: ¶¯»³ÖÐøʱ¼ä
- Öµ: Êý×Ö£¬ÒÔÃëΪµ¥Î»
after/wait
- ˵Ã÷: ¶¯»ÑÓ³Ùʱ¼ä
- Öµ: Êý×Ö£¬ÒÔÃëΪµ¥Î»
Ìî³ä£¨¿ÉÑ¡£©
¿ÉÒÔÔÚ data-scroll-reveal ÊôÐÔÀïÌî³ä£¨Ìí¼Ó£©Ò»Ð©ÀàËƱà³ÌµÄ“Óï¾ä”£¬Ê¹Æä¸üÓпɶÁÐÔ£¬scrollReveal.js Ö§³ÖÒÔÏ“Óï¾ä”£º
- from
- the
- and
- then
- but
- with
- ,
Ò²¾ÍÊÇ¿ÉÒÔÏñÕâÑùд HTML£º
<div data-scroll-reveal="wait 0.3s, then enter left and move 40px over 2s">dowebok.com</div> <div data-scroll-reveal="enter from the left after 0.3s, move 40px, over 2s">Hello world!</div> <div data-scroll-reveal="enter left move 40px over 2s after 0.3s">iPhone 6</div> <div data-scroll-reveal="enter left, move 40px, over 2s, wait 0.3s">I love you</div>
¸ß¼¶Ó÷¨
×Ô¶¨ÒåĬÈÏÖµ
¿ÉÒÔ¸ü¸Ä scrollReveal.js µÄĬÈÏÅäÖã¬È磺
var config = { after: '0s', enter: 'bottom', move: '24px', over: '0.66s', easing: 'ease-in-out', viewportFactor: 0.33, reset: false, init: true }; window.scrollReveal = new scrollReveal(config);
¶¯Ì¬HTML
scrollReveal.init() ·½·¨¿ÉÒÔ¼ì²âËùÓк¬ÓÐ data-scroll-reveal ÊôÐÔµÄÔªËØ£¬²¢½øÐгõʼ»¯£¬ËùÒÔ¶ÔÓÚ¶¯Ì¬¼ÓÔصÄÔªËØ£¬¿ÉÒÔÕâÑù²Ù×÷£º
var config = { enter: 'bottom', move: '40px', over: '0.16s', reset: true, init: false }; window.scrollReveal = new scrollReveal(config); var data = {newElementHtml: '<div data-scroll-reveal>dowebok.com</div>'}; var container = document.getElementById('#container'); container.innerHTML(data.newElementHTML); scrollReveal.init();
תÔØÇë×¢Ã÷£º ÎÄÕÂתÔØ×Ô£º°®Ë¼×ÊÔ´Íø http://www.aseoe.com/show-79-711-1.html