This file contains 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
if ((translateX < (-menuWidth) / 2) || (Math.abs(translateX) / timeTaken > velocity)) { | |
// if menu is open, this represents the close condition | |
if (translateX > menuWidth / 2 || (Math.abs(translateX) / timeTaken > velocity)) { | |
// if menu is closed, this represents the open condition |
This file contains 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
if (translateX === 0 && translateY === 0) { | |
if (isOpen) { | |
appMenu.classList.remove("no-transition"); | |
menu.classList.remove("no-transition"); | |
} else { | |
menu.classList.remove("menu--background-visible"); | |
menu.classList.remove("no-transition"); | |
} | |
} |
This file contains 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 touchEnd(currentX, currentY, translateX, translateY, timeTaken) { | |
isMoving = false; | |
var velocity = 0.3; | |
//... | |
} |
This file contains 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
var newOpacity = (((maxOpacity) * percentage) / 100); |
This file contains 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
overlay.classList.add("no-transition"); | |
var percentageBeforeDif = (Math.abs(moveX) * 100) / menuWidth; | |
var percentage = 100 - percentageBeforeDif; |
This file contains 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 updateUi() { | |
if (isMoving) { | |
var element = document.querySelector(".app-menu-container"); | |
element.style.transform = "translateX(" + moveX + "px)"; | |
element.style.webkitTransform = "translateX(" + moveX + "px)"; | |
requestAnimationFrame(updateUi); | |
} | |
} |
This file contains 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
moveX + (currentX - lastX) |
This file contains 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
if (moveX + (currentX - lastX) < 0 && moveX + (currentX - lastX) > -menuWidth) { | |
moveX = moveX + (currentX - lastX); | |
// ... | |
} |
This file contains 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
if (dragDirection === "vertical") { | |
lastX = currentX; | |
lastY = currentY; | |
} else { | |
evt.preventDefault(); | |
// ... | |
} |
This file contains 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 touchMove(evt, currentX, currentY, translateX, translateY) { | |
if (!dragDirection) { | |
if (Math.abs(translateX) >= Math.abs(translateY)) { | |
dragDirection = "horizontal"; | |
} else { | |
dragDirection = "vertical"; | |
} | |
requestAnimationFrame(updateUi); | |
// this is what actually does the animation (ノ◕ヮ◕)ノ*:・゚✧ |
NewerOlder