Only use touchend when really available and on mobile #345
This commit is contained in:
parent
68d9505015
commit
aca4fcf400
@ -19,7 +19,7 @@ header.dom = function(selector) {
|
||||
header.bind = function() {
|
||||
|
||||
// Event Name
|
||||
var eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click';
|
||||
var eventName = lychee.getEventName();
|
||||
|
||||
/* Buttons */
|
||||
header.dom('#title').on(eventName, function(e) {
|
||||
|
@ -6,8 +6,7 @@
|
||||
$(document).ready(function() {
|
||||
|
||||
/* Event Name */
|
||||
var touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
|
||||
eventName = (touchendSupport===true ? 'touchend' : 'click');
|
||||
var eventName = lychee.getEventName();
|
||||
|
||||
/* Set API error handler */
|
||||
api.onError = lychee.error;
|
||||
|
@ -384,6 +384,15 @@ lychee.loadDropbox = function(callback) {
|
||||
|
||||
}
|
||||
|
||||
lychee.getEventName = function() {
|
||||
|
||||
let touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
|
||||
eventName = (touchendSupport===true ? 'touchend' : 'click');
|
||||
|
||||
return eventName;
|
||||
|
||||
}
|
||||
|
||||
lychee.removeHTML = function(html = '') {
|
||||
|
||||
if (html==='') return html;
|
||||
|
@ -30,7 +30,7 @@ sidebar.bind = function() {
|
||||
// event handlers should be removed before binding a new one.
|
||||
|
||||
// Event Name
|
||||
let eventName = ('ontouchend' in document.documentElement) ? 'touchend' : 'click'
|
||||
let eventName = lychee.getEventName();
|
||||
|
||||
sidebar
|
||||
.dom('#edit_title')
|
||||
|
@ -5,48 +5,48 @@
|
||||
|
||||
swipe = {
|
||||
|
||||
obj: null,
|
||||
tolerance: 150,
|
||||
offset: 0
|
||||
obj : null,
|
||||
tolerance : 150,
|
||||
offset : 0
|
||||
|
||||
}
|
||||
|
||||
swipe.start = function(obj, tolerance) {
|
||||
|
||||
if (obj) swipe.obj = obj;
|
||||
if (tolerance) swipe.tolerance = tolerance;
|
||||
if (obj) swipe.obj = obj
|
||||
if (tolerance) swipe.tolerance = tolerance
|
||||
|
||||
return true;
|
||||
return true
|
||||
|
||||
}
|
||||
|
||||
swipe.move = function(e) {
|
||||
|
||||
if (swipe.obj===null) return false;
|
||||
if (swipe.obj===null) return false
|
||||
|
||||
swipe.offset = -1 * e.x;
|
||||
swipe.offset = -1 * e.x
|
||||
|
||||
swipe.obj.css({
|
||||
WebkitTransform: 'translateX(' + swipe.offset + 'px)',
|
||||
MozTransform: 'translateX(' + swipe.offset + 'px)',
|
||||
transform: 'translateX(' + swipe.offset + 'px)'
|
||||
});
|
||||
WebkitTransform : 'translateX(' + swipe.offset + 'px)',
|
||||
MozTransform : 'translateX(' + swipe.offset + 'px)',
|
||||
transform : 'translateX(' + swipe.offset + 'px)'
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
swipe.stop = function(e, left, right) {
|
||||
|
||||
if (e.x<=-swipe.tolerance) left(true);
|
||||
else if (e.x>=swipe.tolerance) right(true);
|
||||
if (e.x<=-swipe.tolerance) left(true)
|
||||
else if (e.x>=swipe.tolerance) right(true)
|
||||
else if (swipe.obj!==null) {
|
||||
swipe.obj.css({
|
||||
WebkitTransform: 'translateX(0px)',
|
||||
MozTransform: 'translateX(0px)',
|
||||
transform: 'translateX(0px)'
|
||||
});
|
||||
WebkitTransform : 'translateX(0px)',
|
||||
MozTransform : 'translateX(0px)',
|
||||
transform : 'translateX(0px)'
|
||||
})
|
||||
}
|
||||
|
||||
swipe.obj = null;
|
||||
swipe.offset = 0;
|
||||
swipe.obj = null
|
||||
swipe.offset = 0
|
||||
|
||||
}
|
@ -9,17 +9,17 @@ var lychee = { content: $('#content') },
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
/* Event Name */
|
||||
if ('ontouchend' in document.documentElement) eventName = 'touchend';
|
||||
else eventName = 'click';
|
||||
// Event Name
|
||||
var touchendSupport = (/Android|iPhone|iPad|iPod/i).test(navigator.userAgent || navigator.vendor || window.opera) && ('ontouchend' in document.documentElement),
|
||||
eventName = (touchendSupport===true ? 'touchend' : 'click');
|
||||
|
||||
/* Set API error handler */
|
||||
// Set API error handler
|
||||
api.onError = error;
|
||||
|
||||
/* Infobox */
|
||||
// Infobox
|
||||
header.dom('#button_info').on(eventName, sidebar.toggle);
|
||||
|
||||
/* Direct Link */
|
||||
// Direct Link
|
||||
header.dom('#button_direct').on(eventName, function() {
|
||||
|
||||
var link = $('#imageview #image').css('background-image').replace(/"/g,'').replace(/url\(|\)$/ig, '');
|
||||
|
Loading…
Reference in New Issue
Block a user