Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
start [2023/02/09 22:25] – steve.wang | start [2023/02/10 00:06] (current) – steve.wang | ||
---|---|---|---|
Line 22: | Line 22: | ||
transition-property: | transition-property: | ||
transition-duration: | transition-duration: | ||
- | transition-delay: | + | transition-delay: |
cursor: | cursor: | ||
} | } | ||
Line 705: | Line 705: | ||
if (deviceType!=' | if (deviceType!=' | ||
window.addEventListener(" | window.addEventListener(" | ||
- | console.log(' | ||
if (window.innerWidth< | if (window.innerWidth< | ||
// | // | ||
Line 757: | Line 756: | ||
// | // | ||
- | /* | ||
- | let startPoint; | ||
- | window.addEventListener(" | ||
- | console.log(' | ||
- | startPoint=JSON.parse(JSON.stringify(new Point(e.touches[0].clientX, | ||
- | }) | ||
- | window.addEventListener(" | ||
- | console.log(' | ||
- | if (startPoint.x< | ||
- | console.log(' | ||
- | checkIfSwitchImageLeft(e.target) | ||
- | } | ||
- | else { | ||
- | console.log(' | ||
- | checkIfSwitchImageRight(e.target) | ||
- | } | ||
- | }) | ||
- | */ | ||
- | |||
- | document.addEventListener(' | ||
- | document.addEventListener(' | ||
- | |||
- | var xDown = null; | ||
- | var yDown = null; | ||
- | |||
- | function getTouches(evt) { | ||
- | return evt.touches || // browser API | ||
- | | ||
- | } | ||
- | |||
- | function handleTouchStart(evt) { | ||
- | const firstTouch = getTouches(evt)[0]; | ||
- | xDown = firstTouch.clientX; | ||
- | yDown = firstTouch.clientY; | ||
- | }; | ||
- | |||
- | let swipeCooldown=false | ||
- | function handleTouchMove(evt) { | ||
- | if ( ! xDown || ! yDown ) { | ||
- | return; | ||
- | } | ||
- | |||
- | var xUp = evt.touches[0].clientX; | ||
- | var yUp = evt.touches[0].clientY; | ||
- | |||
- | var xDiff = xDown - xUp; | ||
- | var yDiff = yDown - yUp; | ||
- | |||
- | if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/ | ||
- | if ( xDiff > 0 && swipeCooldown==false) { | ||
- | console.log(' | ||
- | swipeCooldown=true | ||
- | checkIfSwitchImageLeft(evt.target) | ||
- | setTimeout(()=> | ||
- | swipeCooldown=false | ||
- | },500) | ||
- | } | ||
- | else if (swipeCooldown==false) { | ||
- | console.log(' | ||
- | swipeCooldown=true | ||
- | checkIfSwitchImageRight(evt.target) | ||
- | setTimeout(()=> | ||
- | swipeCooldown=false | ||
- | },500) | ||
- | } | ||
- | } else { | ||
- | if ( yDiff > 0 ) { | ||
- | /* down swipe */ | ||
- | } else { | ||
- | /* up swipe */ | ||
- | } | ||
- | } | ||
- | /* reset values */ | ||
- | xDown = null; | ||
- | yDown = null; | ||
- | }; | ||
- | |||
- | //swiping code by: https:// | ||
function adaptToOrientationChange (){ | function adaptToOrientationChange (){ | ||
Line 1477: | Line 1398: | ||
buttonsArray.forEach(i => whereButtonsGo.appendChild(i)) | buttonsArray.forEach(i => whereButtonsGo.appendChild(i)) | ||
+ | //STEVE CODE: | ||
+ | |||
+ | |||
+ | /* | ||
+ | let startPoint; | ||
+ | window.addEventListener(" | ||
+ | console.log(' | ||
+ | startPoint=JSON.parse(JSON.stringify(new Point(e.touches[0].clientX, | ||
+ | }) | ||
+ | |||
+ | window.addEventListener(" | ||
+ | console.log(' | ||
+ | if (startPoint.x< | ||
+ | console.log(' | ||
+ | checkIfSwitchImageLeft(e.target) | ||
+ | } | ||
+ | else { | ||
+ | console.log(' | ||
+ | checkIfSwitchImageRight(e.target) | ||
+ | } | ||
+ | }) | ||
+ | */ | ||
+ | |||
+ | window.addEventListener(' | ||
+ | window.addEventListener(' | ||
+ | |||
+ | var xDown = null; | ||
+ | var yDown = null; | ||
+ | |||
+ | function getTouches(evt) { | ||
+ | return evt.touches || // browser API | ||
+ | | ||
+ | } | ||
+ | |||
+ | function handleTouchStart(evt) { | ||
+ | const firstTouch = getTouches(evt)[0]; | ||
+ | xDown = firstTouch.clientX; | ||
+ | yDown = firstTouch.clientY; | ||
+ | }; | ||
+ | |||
+ | let swipeCooldown=false | ||
+ | function handleTouchMove(evt) { | ||
+ | console.log(' | ||
+ | if ( ! xDown || ! yDown ) { | ||
+ | return; | ||
+ | } | ||
+ | console.log(' | ||
+ | var xUp = evt.touches[0].clientX; | ||
+ | var yUp = evt.touches[0].clientY; | ||
+ | |||
+ | var xDiff = xDown - xUp; | ||
+ | var yDiff = yDown - yUp; | ||
+ | |||
+ | if ( Math.abs( xDiff ) > Math.abs( yDiff ) ) {/*most significant*/ | ||
+ | if ( xDiff > 0 && swipeCooldown==false) { | ||
+ | evt.preventDefault() | ||
+ | console.log(' | ||
+ | swipeCooldown=true | ||
+ | checkIfSwitchImageLeft(evt.target) | ||
+ | setTimeout(()=> | ||
+ | swipeCooldown=false | ||
+ | },500) | ||
+ | } | ||
+ | else if (swipeCooldown==false) { | ||
+ | evt.preventDefault() | ||
+ | console.log(' | ||
+ | swipeCooldown=true | ||
+ | checkIfSwitchImageRight(evt.target) | ||
+ | setTimeout(()=> | ||
+ | swipeCooldown=false | ||
+ | },500) | ||
+ | } | ||
+ | } else { | ||
+ | if ( yDiff > 0 ) { | ||
+ | } else { | ||
+ | } | ||
+ | } | ||
+ | /* reset values */ | ||
+ | xDown = null; | ||
+ | yDown = null; | ||
+ | }; | ||
+ | |||
+ | //swiping code by: https:// | ||
</ | </ |