mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPROVEMENT: Detect touch screen
This commit is contained in:
parent
0ed834a7bb
commit
b2001023a6
@ -7,7 +7,7 @@ import $ from 'jquery';
|
|||||||
import Events from '../_events';
|
import Events from '../_events';
|
||||||
import 'jquery-hoverintent/jquery.hoverIntent.js';
|
import 'jquery-hoverintent/jquery.hoverIntent.js';
|
||||||
|
|
||||||
const HoverUI = (($) => {
|
const HoverUI = ($ => {
|
||||||
// Constants
|
// Constants
|
||||||
const W = window;
|
const W = window;
|
||||||
const D = document;
|
const D = document;
|
||||||
@ -36,8 +36,8 @@ const HoverUI = (($) => {
|
|||||||
$target = $target
|
$target = $target
|
||||||
? $target
|
? $target
|
||||||
: $parent
|
: $parent
|
||||||
? $parent.find('.dropdown-menu')
|
? $parent.find('.dropdown-menu')
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
if (!$target || !$target.length) {
|
if (!$target || !$target.length) {
|
||||||
console.warn(`${NAME}: Missing target for:`);
|
console.warn(`${NAME}: Missing target for:`);
|
||||||
@ -51,7 +51,7 @@ const HoverUI = (($) => {
|
|||||||
ui.$triger = $triger;
|
ui.$triger = $triger;
|
||||||
|
|
||||||
// integrate with dropdown-toggle
|
// integrate with dropdown-toggle
|
||||||
$('[data-toggle="dropdown"]').on('click touch', (e) => {
|
$('[data-toggle="dropdown"]').on('click touch', e => {
|
||||||
ui.hide();
|
ui.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -68,8 +68,11 @@ const HoverUI = (($) => {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
$el.on('click touch', (e) => {
|
$el.on('click touch', e => {
|
||||||
if (!$el.data('allow-click')) {
|
if (
|
||||||
|
!$el.data('allow-click') ||
|
||||||
|
(W.IsTouchScreen && !$el.data('allow-touch-click'))
|
||||||
|
) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +154,7 @@ const HoverUI = (($) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// rewrite 'bootstrap/js/dist/dropdown'
|
// rewrite 'bootstrap/js/dist/dropdown'
|
||||||
$('[data-toggle="dropdown"]').on('click touch', (e) => {
|
$('[data-toggle="dropdown"]').on('click touch', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
const $el = $(e.currentTarget);
|
const $el = $(e.currentTarget);
|
||||||
|
@ -15,7 +15,7 @@ import FormBasics from './_components/_ui.form.basics';
|
|||||||
import SmoothScroll from 'smooth-scroll';
|
import SmoothScroll from 'smooth-scroll';
|
||||||
const smoothScroll = SmoothScroll();
|
const smoothScroll = SmoothScroll();
|
||||||
|
|
||||||
const MainUI = (($) => {
|
const MainUI = ($ => {
|
||||||
// Constants
|
// Constants
|
||||||
const W = window;
|
const W = window;
|
||||||
const D = document;
|
const D = document;
|
||||||
@ -126,6 +126,8 @@ const MainUI = (($) => {
|
|||||||
hash: '',
|
hash: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
W.IsTouchScreen = 'ontouchstart' in window || navigator.msMaxTouchPoints;
|
||||||
|
|
||||||
class MainUI {
|
class MainUI {
|
||||||
// Static methods
|
// Static methods
|
||||||
|
|
||||||
@ -174,7 +176,7 @@ const MainUI = (($) => {
|
|||||||
//
|
//
|
||||||
|
|
||||||
// scroll links
|
// scroll links
|
||||||
$('.js-scrollTo').on('click', (e) => {
|
$('.js-scrollTo').on('click', e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const el = e.currentTarget;
|
const el = e.currentTarget;
|
||||||
const $el = $(e.currentTarget);
|
const $el = $(e.currentTarget);
|
||||||
@ -203,7 +205,7 @@ const MainUI = (($) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// data-set links
|
// data-set links
|
||||||
$('[data-set-target]').on('click', (e) => {
|
$('[data-set-target]').on('click', e => {
|
||||||
const $el = $(e.currentTarget);
|
const $el = $(e.currentTarget);
|
||||||
const $target = $($el.data('set-target'));
|
const $target = $($el.data('set-target'));
|
||||||
|
|
||||||
@ -227,7 +229,7 @@ const MainUI = (($) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// emulate links
|
// emulate links
|
||||||
$('.a[data-href]').on('click', (e) => {
|
$('.a[data-href]').on('click', e => {
|
||||||
const $el = $(e.currentTarget);
|
const $el = $(e.currentTarget);
|
||||||
const href = $el.data('href');
|
const href = $el.data('href');
|
||||||
if (!href.length) {
|
if (!href.length) {
|
||||||
|
Loading…
Reference in New Issue
Block a user