Here are a few common tasks you might do in your templates, as they would be written in ExpressionEngine vs. Craft CMS.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Determine if an element is in the visible viewport | |
| function isInViewport(element) { | |
| var rect = element.getBoundingClientRect(); | |
| var html = document.documentElement; | |
| return ( | |
| rect.top >= 0 && | |
| rect.left >= 0 && | |
| rect.bottom <= (window.innerHeight || html.clientHeight) && | |
| rect.right <= (window.innerWidth || html.clientWidth) | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // prevent back/forward gestures when scrolling an element left/right on OS X | |
| var preventHistorySwipe = function(element) { | |
| // not even on the right platform bro | |
| if (navigator.userAgent.indexOf('Macintosh') === -1) return; | |
| element.addEventListener('mousewheel', function(e) { | |
| var x = e.wheelDeltaX; | |
| // scrolling up or down? then i don't give a shit | |
| if (x === 0) return; |
NewerOlder