mirror of
https://github.com/tenrok/bootstrap.git
synced 2026-06-17 19:21:23 +03:00
Extract Component config functionality to a separate class (#33872)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
This commit is contained in:
+17
-11
@@ -5,8 +5,9 @@
|
||||
* --------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
import Config from './config'
|
||||
import EventHandler from '../dom/event-handler'
|
||||
import { execute, typeCheckConfig } from './index'
|
||||
import { execute } from './index'
|
||||
|
||||
/**
|
||||
* Constants
|
||||
@@ -40,8 +41,9 @@ const DefaultType = {
|
||||
* Class definition
|
||||
*/
|
||||
|
||||
class Swipe {
|
||||
class Swipe extends Config {
|
||||
constructor(element, config) {
|
||||
super()
|
||||
this._element = element
|
||||
|
||||
if (!element || !Swipe.isSupported()) {
|
||||
@@ -54,6 +56,19 @@ class Swipe {
|
||||
this._initEvents()
|
||||
}
|
||||
|
||||
// Getters
|
||||
static get Default() {
|
||||
return Default
|
||||
}
|
||||
|
||||
static get DefaultType() {
|
||||
return DefaultType
|
||||
}
|
||||
|
||||
static get NAME() {
|
||||
return NAME
|
||||
}
|
||||
|
||||
// Public
|
||||
dispose() {
|
||||
EventHandler.off(this._element, EVENT_KEY)
|
||||
@@ -118,15 +133,6 @@ class Swipe {
|
||||
}
|
||||
}
|
||||
|
||||
_getConfig(config) {
|
||||
config = {
|
||||
...Default,
|
||||
...(typeof config === 'object' ? config : {})
|
||||
}
|
||||
typeCheckConfig(NAME, config, DefaultType)
|
||||
return config
|
||||
}
|
||||
|
||||
_eventIsPointerPenTouch(event) {
|
||||
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user