Last active
December 12, 2022 23:57
-
-
Save renakdup/95e05e8afe853526aae19b3f373f9448 to your computer and use it in GitHub Desktop.
Revisions
-
renakdup revised this gist
Dec 12, 2022 . 1 changed file with 60 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ // Detect swipe event. Detect touch swipe event. // Example detectSwipeEvent(document.getElementsByClassName('js-mobile-nav__background')[0], function (orientation) { console.log(orientation) }); /** * @param element js element * @param callback Your callback invoke on swipe event. Attribute "swipe orientation" transfer to callback. */ function detectSwipeEvent (element, callback) { element.addEventListener('touchstart', startTouch, false) element.addEventListener('touchmove', moveTouch, false) // Swipe Up / Down / Left / Right var initialX = null var initialY = null function startTouch (e) { initialX = e.touches[ 0 ].clientX initialY = e.touches[ 0 ].clientY } function moveTouch (e) { if (initialX === null) { return } if (initialY === null) { return } var currentX = e.touches[ 0 ].clientX var currentY = e.touches[ 0 ].clientY var diffX = initialX - currentX var diffY = initialY - currentY if (Math.abs(diffX) > Math.abs(diffY)) { // sliding horizontally if (diffX > 0) { callback('left') } else { callback('right') } } else { // sliding vertically if (diffY > 0) { callback('up') } else { callback('down') } } initialX = null initialY = null e.preventDefault() } } -
renakdup revised this gist
Dec 12, 2022 . No changes.There are no files selected for viewing
-
renakdup renamed this gist
Aug 7, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
renakdup revised this gist
Aug 7, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ var rand = min + Math.floor(Math.random() * (max + 1 - min)); -
renakdup revised this gist
Aug 6, 2017 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +0,0 @@ -
renakdup revised this gist
Aug 6, 2017 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ sdfsdfsdfsd -
renakdup revised this gist
Aug 6, 2017 . No changes.There are no files selected for viewing
-
renakdup revised this gist
Aug 6, 2017 . No changes.There are no files selected for viewing
-
renakdup renamed this gist
Aug 6, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
renakdup created this gist
Aug 6, 2017 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n); }