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
| function isMobile() { | |
| return !('onpointerdown' in document.documentElement); | |
| } |
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
| // source: https://greensock.com/forums/topic/18719-how-to-manage-gsap-animation-in-mobile-device/ | |
| function installMediaQueryWatcher(mediaQuery, layoutChangedCallback) { | |
| var mql = window.matchMedia(mediaQuery); | |
| mql.addListener(function (e) { return layoutChangedCallback(e.matches); }); | |
| layoutChangedCallback(mql.matches); | |
| } | |
| // example below | |
| installMediaQueryWatcher("(min-width: 600px)", function(matches) { |
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
| function matchHeight(wrapperEl, matchEl){ | |
| var maxHeight = 0; | |
| var element = jQuery(wrapperEl); | |
| jQuery(element).find(matchEl).each(function(index, element){ | |
| // reset previous min-height | |
| jQuery(this).css('min-height', 0); | |
| if (jQuery(this).outerHeight() > maxHeight) { maxHeight = jQuery(this).outerHeight(); } | |
| }); | |
| jQuery(element).find(matchEl).css('min-height', maxHeight); | |
| } |
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
| body{ | |
| -ms-overflow-style: none; // IE 10+ | |
| overflow: -moz-scrollbars-none; // Firefox | |
| } | |
| body::-webkit-scrollbar { | |
| display: none; // Safari and Chrome | |
| } |
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
| function random(min, max) { | |
| if (max == null) { max = min; min = 0; } | |
| if (min > max) { var tmp = min; min = max; max = tmp; } | |
| return min + (max - min) * Math.random(); | |
| } |
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
| <button type="button" class="navbar-toggle collapsed"> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| <span class="icon-bar"></span> | |
| </button> | |
| .navbar-toggle { | |
| outline: none; | |
| width: 30px; | |
| height: 50px; |
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
| function hasClass(ele,cls) { | |
| return !!ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)')); | |
| } | |
| function addClass(ele,cls) { | |
| if (!hasClass(ele,cls)) ele.className += " "+cls; | |
| } | |
| function removeClass(ele,cls) { | |
| if (hasClass(ele,cls)) { | |
| var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)'); | |
| ele.className=ele.className.replace(reg,''); |
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
| function Event(name){ | |
| this.name = name; | |
| this.callbacks = []; | |
| } | |
| Event.prototype.registerCallback = function(callback){ | |
| this.callbacks.push(callback); | |
| } | |
| function Reactor(){ | |
| this.events = {}; |
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
| function Observable() { | |
| var observers = []; | |
| this.sendMessage = function(msg){ | |
| for(var i = 0, length = observers.length; i < length; i++){ | |
| observers[i].notify(msg) | |
| } | |
| } | |
| this.addObserver = function(observer){ | |
| observers.push(observer) | |
| } |
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
| window.onscroll = myScroll; | |
| var counter = 0; // Global Variable | |
| function myScroll(){ | |
| var val = document.getElementById("value"); | |
| val.innerHTML = 'pageYOffset = ' + window.pageYOffset; | |
| if(counter == 0){ // if counter is 1, it will not execute | |
| if(window.pageYOffset > 300){ | |
| alert('You have scrolled to second div'); | |
| counter++; // increment the counter by 1, new value = 1 | |
| } |