MCPcopy
hub / github.com/Mango/slideout / Slideout

Function Slideout

index.js:61–104  ·  view source on GitHub ↗

* Slideout constructor

(options)

Source from the content-addressed store, hash-verified

59 * Slideout constructor
60 */
61function Slideout(options) {
62 options = options || {};
63
64 // Sets default values
65 this._startOffsetX = 0;
66 this._currentOffsetX = 0;
67 this._opening = false;
68 this._moved = false;
69 this._opened = false;
70 this._preventOpen = false;
71 this._touch = options.touch === undefined ? true : options.touch && true;
72 this._side = options.side || 'left';
73
74 // Sets panel
75 this.panel = options.panel;
76 this.menu = options.menu;
77
78 // Sets classnames
79 if (!this.panel.classList.contains('slideout-panel')) {
80 this.panel.classList.add('slideout-panel');
81 }
82 if (!this.panel.classList.contains('slideout-panel-' + this._side)) {
83 this.panel.classList.add('slideout-panel-' + this._side);
84 }
85 if (!this.menu.classList.contains('slideout-menu')) {
86 this.menu.classList.add('slideout-menu');
87 }
88 if (!this.menu.classList.contains('slideout-menu-' + this._side)) {
89 this.menu.classList.add('slideout-menu-' + this._side);
90 }
91
92 // Sets options
93 this._fx = options.fx || 'ease';
94 this._duration = parseInt(options.duration, 10) || 300;
95 this._tolerance = parseInt(options.tolerance, 10) || 70;
96 this._padding = this._translateTo = parseInt(options.padding, 10) || 256;
97 this._orientation = this._side === 'right' ? -1 : 1;
98 this._translateTo *= this._orientation;
99
100 // Init touch events
101 if (this._touch) {
102 this._initTouchEvents();
103 }
104}
105
106/**
107 * Inherits from Emitter

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected