Skip to content

Commit 2b04cbc

Browse files
committed
maint(pat-bumper): Switch to class based patterns.
1 parent bae3f55 commit 2b04cbc

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/pat/bumper/bumper.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
/**
2-
* Patterns bumper - Add bumping classes for sticky elements.
3-
*/
4-
5-
import Base from "../../core/base";
1+
import { BasePattern } from "@patternslib/patternslib/src/core/basepattern";
62
import dom from "../../core/dom";
73
import Parser from "../../core/parser";
4+
import registry from "@patternslib/patternslib/src/core/registry";
85
import utils from "../../core/utils";
96

107
export const parser = new Parser("bumper");
@@ -14,15 +11,14 @@ parser.addArgument("bump-remove");
1411
parser.addArgument("unbump-add");
1512
parser.addArgument("unbump-remove", "bumped");
1613

17-
export default Base.extend({
18-
name: "bumper",
19-
trigger: ".pat-bumper",
14+
class Pattern extends BasePattern {
15+
static name = "bumper";
16+
static trigger = ".pat-bumper";
17+
static parser = parser;
2018

2119
async init() {
2220
// Based on: https://davidwalsh.name/detect-sticky
2321

24-
this.options = parser.parse(this.el, this.options);
25-
2622
this.target_element = this.options.selector
2723
? document.querySelector(this.options.selector)
2824
: this.el;
@@ -31,7 +27,7 @@ export default Base.extend({
3127
// e.g. CSS applied for injected content.
3228
await utils.timeout(1);
3329
this._init();
34-
},
30+
}
3531

3632
_init() {
3733
const scroll_container_y = dom.find_scroll_container(
@@ -76,7 +72,7 @@ export default Base.extend({
7672
);
7773
observer_x.observe(this.el);
7874
}
79-
},
75+
}
8076

8177
_intersection_observer_callback(entries) {
8278
const el = this.target_element;
@@ -134,5 +130,10 @@ export default Base.extend({
134130
el.classList.remove("bumped-bottom");
135131
}
136132
}
137-
},
138-
});
133+
}
134+
}
135+
136+
registry.register(Pattern);
137+
138+
export default Pattern;
139+
export { Pattern };

0 commit comments

Comments
 (0)