@materializecss/materialize 2.0.1-alpha → 2.0.2-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Gruntfile.js +5 -2
- package/dist/css/materialize.css +90 -86
- package/dist/css/materialize.min.css +2 -2
- package/dist/js/materialize.js +2797 -2705
- package/dist/js/materialize.min.js +2 -8967
- package/dist/js/materialize.min.js.map +1 -1
- package/package.json +1 -1
- package/sass/components/_collapsible.scss +0 -41
- package/sass/components/_global.scss +3 -2
- package/sass/components/_icons-material-design.scss +2 -1
- package/sass/components/_navbar.scss +6 -3
- package/sass/components/_sidenav.scss +66 -37
- package/sass/components/_theme_variables.scss +2 -2
- package/sass/components/_typography.scss +2 -2
- package/sass/components/forms/_input-fields.scss +4 -10
- package/sass/materialize.scss +0 -4
- package/src/autocomplete.ts +188 -94
- package/src/buttons.ts +225 -260
- package/src/cards.ts +5 -6
- package/src/carousel.ts +611 -542
- package/src/characterCounter.ts +50 -21
- package/src/chips.ts +152 -63
- package/src/collapsible.ts +97 -32
- package/src/component.ts +99 -10
- package/src/datepicker.ts +905 -726
- package/src/dropdown.ts +576 -484
- package/src/edges.ts +4 -4
- package/src/forms.ts +17 -14
- package/src/global.ts +55 -324
- package/src/materialbox.ts +354 -298
- package/src/modal.ts +296 -211
- package/src/parallax.ts +129 -105
- package/src/pushpin.ts +148 -103
- package/src/range.ts +166 -150
- package/src/scrollspy.ts +214 -174
- package/src/select.ts +434 -398
- package/src/sidenav.ts +447 -381
- package/src/slider.ts +421 -362
- package/src/tabs.ts +276 -222
- package/src/tapTarget.ts +246 -213
- package/src/timepicker.ts +738 -614
- package/src/toasts.ts +254 -230
- package/src/tooltip.ts +315 -252
- package/src/utils.ts +271 -0
- package/src/waves.ts +10 -10
package/src/parallax.ts
CHANGED
|
@@ -1,125 +1,149 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
import { Utils } from "./utils";
|
|
2
|
+
import { Component, BaseOptions, InitElements, MElement } from "./component";
|
|
3
|
+
|
|
4
|
+
export interface ParallaxOptions extends BaseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The minimum width of the screen, in pixels, where the parallax functionality starts working.
|
|
7
|
+
* @default 0
|
|
8
|
+
*/
|
|
9
|
+
responsiveThreshold: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
let _defaults: ParallaxOptions = {
|
|
13
|
+
responsiveThreshold: 0 // breakpoint for swipeable
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class Parallax extends Component<ParallaxOptions> {
|
|
17
|
+
private _enabled: boolean;
|
|
18
|
+
private _img: HTMLImageElement;
|
|
19
|
+
static _parallaxes: Parallax[] = [];
|
|
20
|
+
static _handleScrollThrottled: () => any;
|
|
21
|
+
static _handleWindowResizeThrottled: () => any;
|
|
22
|
+
|
|
23
|
+
constructor(el: HTMLElement, options: Partial<ParallaxOptions>) {
|
|
24
|
+
super(el, options, Parallax);
|
|
25
|
+
(this.el as any).M_Parallax = this;
|
|
26
|
+
|
|
27
|
+
this.options = {
|
|
28
|
+
...Parallax.defaults,
|
|
29
|
+
...options
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
this._enabled = window.innerWidth > this.options.responsiveThreshold;
|
|
33
|
+
this._img = this.el.querySelector('img');
|
|
34
|
+
this._updateParallax();
|
|
35
|
+
this._setupEventHandlers();
|
|
36
|
+
this._setupStyles();
|
|
37
|
+
Parallax._parallaxes.push(this);
|
|
38
|
+
}
|
|
27
39
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
static get defaults(): ParallaxOptions {
|
|
41
|
+
return _defaults;
|
|
42
|
+
}
|
|
31
43
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
44
|
+
/**
|
|
45
|
+
* Initializes instance of Parallax.
|
|
46
|
+
* @param el HTML element.
|
|
47
|
+
* @param options Component options.
|
|
48
|
+
*/
|
|
49
|
+
static init(el: HTMLElement, options?: Partial<ParallaxOptions>): Parallax;
|
|
50
|
+
/**
|
|
51
|
+
* Initializes instances of Parallax.
|
|
52
|
+
* @param els HTML elements.
|
|
53
|
+
* @param options Component options.
|
|
54
|
+
*/
|
|
55
|
+
static init(els: InitElements<MElement>, options?: Partial<ParallaxOptions>): Parallax[];
|
|
56
|
+
/**
|
|
57
|
+
* Initializes instances of Parallax.
|
|
58
|
+
* @param els HTML elements.
|
|
59
|
+
* @param options Component options.
|
|
60
|
+
*/
|
|
61
|
+
static init(els: HTMLElement | InitElements<MElement>, options: Partial<ParallaxOptions> = {}): Parallax | Parallax[] {
|
|
62
|
+
return super.init(els, options, Parallax);
|
|
63
|
+
}
|
|
35
64
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
65
|
+
static getInstance(el: HTMLElement): Parallax {
|
|
66
|
+
return (el as any).M_Parallax;
|
|
67
|
+
}
|
|
40
68
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
69
|
+
destroy() {
|
|
70
|
+
Parallax._parallaxes.splice(Parallax._parallaxes.indexOf(this), 1);
|
|
71
|
+
this._img.style.transform = '';
|
|
72
|
+
this._removeEventHandlers();
|
|
73
|
+
(this.el as any).M_Parallax = undefined;
|
|
74
|
+
}
|
|
47
75
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
76
|
+
static _handleScroll() {
|
|
77
|
+
for (let i = 0; i < Parallax._parallaxes.length; i++) {
|
|
78
|
+
let parallaxInstance = Parallax._parallaxes[i];
|
|
79
|
+
parallaxInstance._updateParallax.call(parallaxInstance);
|
|
53
80
|
}
|
|
81
|
+
}
|
|
54
82
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
83
|
+
static _handleWindowResize() {
|
|
84
|
+
for (let i = 0; i < Parallax._parallaxes.length; i++) {
|
|
85
|
+
let parallaxInstance = Parallax._parallaxes[i];
|
|
86
|
+
parallaxInstance._enabled =
|
|
87
|
+
window.innerWidth > parallaxInstance.options.responsiveThreshold;
|
|
61
88
|
}
|
|
89
|
+
}
|
|
62
90
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
if (Parallax.
|
|
67
|
-
Parallax._handleScrollThrottled =
|
|
68
|
-
window.addEventListener('scroll', Parallax._handleScrollThrottled);
|
|
69
|
-
Parallax._handleWindowResizeThrottled = M.throttle(Parallax._handleWindowResize, 5);
|
|
70
|
-
window.addEventListener('resize', Parallax._handleWindowResizeThrottled);
|
|
91
|
+
_setupEventHandlers() {
|
|
92
|
+
this._img.addEventListener('load', this._handleImageLoad);
|
|
93
|
+
if (Parallax._parallaxes.length === 0) {
|
|
94
|
+
if (!Parallax._handleScrollThrottled){
|
|
95
|
+
Parallax._handleScrollThrottled = Utils.throttle(Parallax._handleScroll, 5);
|
|
71
96
|
}
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_removeEventHandlers() {
|
|
75
|
-
this._img.removeEventListener('load', this._handleImageLoadBound);
|
|
76
|
-
if (Parallax._parallaxes.length === 0) {
|
|
77
|
-
window.removeEventListener('scroll', Parallax._handleScrollThrottled);
|
|
78
|
-
window.removeEventListener('resize', Parallax._handleWindowResizeThrottled);
|
|
97
|
+
if (!Parallax._handleWindowResizeThrottled){
|
|
98
|
+
Parallax._handleWindowResizeThrottled = Utils.throttle(Parallax._handleWindowResize, 5);
|
|
79
99
|
}
|
|
100
|
+
window.addEventListener('scroll', Parallax._handleScrollThrottled);
|
|
101
|
+
window.addEventListener('resize', Parallax._handleWindowResizeThrottled);
|
|
80
102
|
}
|
|
103
|
+
}
|
|
81
104
|
|
|
82
|
-
|
|
83
|
-
|
|
105
|
+
_removeEventHandlers() {
|
|
106
|
+
this._img.removeEventListener('load', this._handleImageLoad);
|
|
107
|
+
if (Parallax._parallaxes.length === 0) {
|
|
108
|
+
window.removeEventListener('scroll', Parallax._handleScrollThrottled);
|
|
109
|
+
window.removeEventListener('resize', Parallax._handleWindowResizeThrottled);
|
|
84
110
|
}
|
|
111
|
+
}
|
|
85
112
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
113
|
+
_setupStyles() {
|
|
114
|
+
this._img.style.opacity = '1';
|
|
115
|
+
}
|
|
89
116
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
return {
|
|
94
|
-
top: box.top + window.pageYOffset - docElem.clientTop,
|
|
95
|
-
left: box.left + window.pageXOffset - docElem.clientLeft
|
|
96
|
-
};
|
|
97
|
-
}
|
|
117
|
+
_handleImageLoad = () => {
|
|
118
|
+
this._updateParallax();
|
|
119
|
+
}
|
|
98
120
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const windowBottom = scrollTop + windowHeight;
|
|
108
|
-
const percentScrolled = (windowBottom - top) / (containerHeight + windowHeight);
|
|
109
|
-
const parallax = parallaxDist * percentScrolled;
|
|
110
|
-
|
|
111
|
-
if (!this._enabled) {
|
|
112
|
-
this._img.style.transform = '';
|
|
113
|
-
}
|
|
114
|
-
else if (bottom > scrollTop && top < scrollTop + windowHeight) {
|
|
115
|
-
this._img.style.transform = `translate3D(-50%, ${parallax}px, 0)`;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
121
|
+
private _offset(el: Element) {
|
|
122
|
+
const box = el.getBoundingClientRect();
|
|
123
|
+
const docElem = document.documentElement;
|
|
124
|
+
return {
|
|
125
|
+
top: box.top + window.pageYOffset - docElem.clientTop,
|
|
126
|
+
left: box.left + window.pageXOffset - docElem.clientLeft
|
|
127
|
+
};
|
|
128
|
+
}
|
|
118
129
|
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
_updateParallax() {
|
|
131
|
+
const containerHeight = this.el.getBoundingClientRect().height > 0 ? (this.el.parentNode as any).offsetHeight : 500;
|
|
132
|
+
const imgHeight = this._img.offsetHeight;
|
|
133
|
+
const parallaxDist = imgHeight - containerHeight;
|
|
134
|
+
const bottom = this._offset(this.el).top + containerHeight;
|
|
135
|
+
const top = this._offset(this.el).top;
|
|
136
|
+
const scrollTop = Utils.getDocumentScrollTop();
|
|
137
|
+
const windowHeight = window.innerHeight;
|
|
138
|
+
const windowBottom = scrollTop + windowHeight;
|
|
139
|
+
const percentScrolled = (windowBottom - top) / (containerHeight + windowHeight);
|
|
140
|
+
const parallax = parallaxDist * percentScrolled;
|
|
141
|
+
|
|
142
|
+
if (!this._enabled) {
|
|
143
|
+
this._img.style.transform = '';
|
|
144
|
+
}
|
|
145
|
+
else if (bottom > scrollTop && top < scrollTop + windowHeight) {
|
|
146
|
+
this._img.style.transform = `translate3D(-50%, ${parallax}px, 0)`;
|
|
121
147
|
}
|
|
122
148
|
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
149
|
+
}
|
package/src/pushpin.ts
CHANGED
|
@@ -1,120 +1,165 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
1
|
+
import { Utils } from "./utils";
|
|
2
|
+
import { Component, BaseOptions, InitElements, MElement } from "./component";
|
|
3
|
+
|
|
4
|
+
export interface PushpinOptions extends BaseOptions {
|
|
5
|
+
/**
|
|
6
|
+
* The distance in pixels from the top of the page where
|
|
7
|
+
* the element becomes fixed.
|
|
8
|
+
* @default 0
|
|
9
|
+
*/
|
|
10
|
+
top: number;
|
|
11
|
+
/**
|
|
12
|
+
* The distance in pixels from the top of the page where
|
|
13
|
+
* the elements stops being fixed.
|
|
14
|
+
* @default Infinity
|
|
15
|
+
*/
|
|
16
|
+
bottom: number;
|
|
17
|
+
/**
|
|
18
|
+
* The offset from the top the element will be fixed at.
|
|
19
|
+
* @default 0
|
|
20
|
+
*/
|
|
21
|
+
offset: number;
|
|
22
|
+
/**
|
|
23
|
+
* Callback function called when pushpin position changes.
|
|
24
|
+
* You are provided with a position string.
|
|
25
|
+
* @default null
|
|
26
|
+
*/
|
|
27
|
+
onPositionChange: (position: "pinned" | "pin-top" | "pin-bottom") => void;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
let _defaults = {
|
|
31
|
+
top: 0,
|
|
32
|
+
bottom: Infinity,
|
|
33
|
+
offset: 0,
|
|
34
|
+
onPositionChange: null
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export class Pushpin extends Component<PushpinOptions> {
|
|
38
|
+
static _pushpins: any[];
|
|
39
|
+
originalOffset: any;
|
|
40
|
+
|
|
41
|
+
constructor(el: HTMLElement, options: Partial<PushpinOptions>) {
|
|
42
|
+
super(el, options, Pushpin);
|
|
43
|
+
(this.el as any).M_Pushpin = this;
|
|
44
|
+
|
|
45
|
+
this.options = {
|
|
46
|
+
...Pushpin.defaults,
|
|
47
|
+
...options
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
this.originalOffset = (this.el as HTMLElement).offsetTop;
|
|
51
|
+
Pushpin._pushpins.push(this);
|
|
52
|
+
this._setupEventHandlers();
|
|
53
|
+
this._updatePosition();
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static get defaults(): PushpinOptions {
|
|
57
|
+
return _defaults;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Initializes instance of Pushpin.
|
|
62
|
+
* @param el HTML element.
|
|
63
|
+
* @param options Component options.
|
|
64
|
+
*/
|
|
65
|
+
static init(el: HTMLElement, options?: Partial<PushpinOptions>): Pushpin;
|
|
66
|
+
/**
|
|
67
|
+
* Initializes instances of Pushpin.
|
|
68
|
+
* @param els HTML elements.
|
|
69
|
+
* @param options Component options.
|
|
70
|
+
*/
|
|
71
|
+
static init(els: InitElements<MElement>, options?: Partial<PushpinOptions>): Pushpin[];
|
|
72
|
+
/**
|
|
73
|
+
* Initializes instances of Pushpin.
|
|
74
|
+
* @param els HTML elements.
|
|
75
|
+
* @param options Component options.
|
|
76
|
+
*/
|
|
77
|
+
static init(els: HTMLElement | InitElements<MElement>, options: Partial<PushpinOptions> = {}): Pushpin | Pushpin[] {
|
|
78
|
+
return super.init(els, options, Pushpin);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
static getInstance(el: HTMLElement): Pushpin {
|
|
82
|
+
return (el as any).M_Pushpin;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
destroy() {
|
|
86
|
+
(this.el as HTMLElement).style.top = null;
|
|
87
|
+
this._removePinClasses();
|
|
88
|
+
// Remove pushpin Inst
|
|
89
|
+
let index = Pushpin._pushpins.indexOf(this);
|
|
90
|
+
Pushpin._pushpins.splice(index, 1);
|
|
91
|
+
if (Pushpin._pushpins.length === 0) {
|
|
92
|
+
this._removeEventHandlers();
|
|
23
93
|
}
|
|
94
|
+
(this.el as any).M_Pushpin = undefined;
|
|
95
|
+
}
|
|
24
96
|
|
|
25
|
-
|
|
26
|
-
|
|
97
|
+
static _updateElements() {
|
|
98
|
+
for (let elIndex in Pushpin._pushpins) {
|
|
99
|
+
let pInstance = Pushpin._pushpins[elIndex];
|
|
100
|
+
pInstance._updatePosition();
|
|
27
101
|
}
|
|
102
|
+
}
|
|
28
103
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
104
|
+
_setupEventHandlers() {
|
|
105
|
+
document.addEventListener('scroll', Pushpin._updateElements);
|
|
106
|
+
}
|
|
32
107
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
108
|
+
_removeEventHandlers() {
|
|
109
|
+
document.removeEventListener('scroll', Pushpin._updateElements);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
_updatePosition() {
|
|
113
|
+
let scrolled = Utils.getDocumentScrollTop() + this.options.offset;
|
|
37
114
|
|
|
38
|
-
|
|
39
|
-
|
|
115
|
+
if (
|
|
116
|
+
this.options.top <= scrolled &&
|
|
117
|
+
this.options.bottom >= scrolled &&
|
|
118
|
+
!this.el.classList.contains('pinned')
|
|
119
|
+
) {
|
|
40
120
|
this._removePinClasses();
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
Pushpin._pushpins.splice(index, 1);
|
|
44
|
-
if (Pushpin._pushpins.length === 0) {
|
|
45
|
-
this._removeEventHandlers();
|
|
46
|
-
}
|
|
47
|
-
(this.el as any).M_Pushpin = undefined;
|
|
48
|
-
}
|
|
121
|
+
(this.el as HTMLElement).style.top = `${this.options.offset}px`;
|
|
122
|
+
this.el.classList.add('pinned');
|
|
49
123
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
pInstance._updatePosition();
|
|
124
|
+
// onPositionChange callback
|
|
125
|
+
if (typeof this.options.onPositionChange === 'function') {
|
|
126
|
+
this.options.onPositionChange.call(this, 'pinned');
|
|
54
127
|
}
|
|
55
128
|
}
|
|
56
129
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
document.removeEventListener('scroll', Pushpin._updateElements);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_updatePosition() {
|
|
66
|
-
let scrolled = M.getDocumentScrollTop() + this.options.offset;
|
|
67
|
-
|
|
68
|
-
if (
|
|
69
|
-
this.options.top <= scrolled &&
|
|
70
|
-
this.options.bottom >= scrolled &&
|
|
71
|
-
!this.el.classList.contains('pinned')
|
|
72
|
-
) {
|
|
73
|
-
this._removePinClasses();
|
|
74
|
-
(this.el as HTMLElement).style.top = `${this.options.offset}px`;
|
|
75
|
-
this.el.classList.add('pinned');
|
|
76
|
-
|
|
77
|
-
// onPositionChange callback
|
|
78
|
-
if (typeof this.options.onPositionChange === 'function') {
|
|
79
|
-
this.options.onPositionChange.call(this, 'pinned');
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Add pin-top (when scrolled position is above top)
|
|
84
|
-
if (scrolled < this.options.top && !this.el.classList.contains('pin-top')) {
|
|
85
|
-
this._removePinClasses();
|
|
86
|
-
(this.el as HTMLElement).style.top = '0';
|
|
87
|
-
this.el.classList.add('pin-top');
|
|
88
|
-
|
|
89
|
-
// onPositionChange callback
|
|
90
|
-
if (typeof this.options.onPositionChange === 'function') {
|
|
91
|
-
this.options.onPositionChange.call(this, 'pin-top');
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// Add pin-bottom (when scrolled position is below bottom)
|
|
96
|
-
if (scrolled > this.options.bottom && !this.el.classList.contains('pin-bottom')) {
|
|
97
|
-
this._removePinClasses();
|
|
98
|
-
this.el.classList.add('pin-bottom');
|
|
99
|
-
(this.el as HTMLElement).style.top = `${this.options.bottom - this.originalOffset}px`;
|
|
130
|
+
// Add pin-top (when scrolled position is above top)
|
|
131
|
+
if (scrolled < this.options.top && !this.el.classList.contains('pin-top')) {
|
|
132
|
+
this._removePinClasses();
|
|
133
|
+
(this.el as HTMLElement).style.top = '0';
|
|
134
|
+
this.el.classList.add('pin-top');
|
|
100
135
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
136
|
+
// onPositionChange callback
|
|
137
|
+
if (typeof this.options.onPositionChange === 'function') {
|
|
138
|
+
this.options.onPositionChange.call(this, 'pin-top');
|
|
105
139
|
}
|
|
106
140
|
}
|
|
107
141
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
this.
|
|
111
|
-
this.el.classList.
|
|
112
|
-
this.el.
|
|
113
|
-
}
|
|
142
|
+
// Add pin-bottom (when scrolled position is below bottom)
|
|
143
|
+
if (scrolled > this.options.bottom && !this.el.classList.contains('pin-bottom')) {
|
|
144
|
+
this._removePinClasses();
|
|
145
|
+
this.el.classList.add('pin-bottom');
|
|
146
|
+
(this.el as HTMLElement).style.top = `${this.options.bottom - this.originalOffset}px`;
|
|
114
147
|
|
|
115
|
-
|
|
116
|
-
|
|
148
|
+
// onPositionChange callback
|
|
149
|
+
if (typeof this.options.onPositionChange === 'function') {
|
|
150
|
+
this.options.onPositionChange.call(this, 'pin-bottom');
|
|
151
|
+
}
|
|
117
152
|
}
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
_removePinClasses() {
|
|
156
|
+
// IE 11 bug (can't remove multiple classes in one line)
|
|
157
|
+
this.el.classList.remove('pin-top');
|
|
158
|
+
this.el.classList.remove('pinned');
|
|
159
|
+
this.el.classList.remove('pin-bottom');
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
static {
|
|
163
|
+
Pushpin._pushpins = [];
|
|
164
|
+
}
|
|
165
|
+
}
|