Skip to content

Commit 2223ff4

Browse files
committed
Use :hover for .hover
1 parent 4373664 commit 2223ff4

File tree

3 files changed

+4
-44
lines changed

3 files changed

+4
-44
lines changed

src/generator/css.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ class Rules {
5757
this.reset();
5858
this.custom_properties = {};
5959
this.uniforms = {};
60-
this.hover = false;
6160
this.content = {};
6261
}
6362

@@ -670,9 +669,6 @@ class Rules {
670669
let name = token.name.substr(1);
671670
let fn = Selector[name];
672671
if (fn) {
673-
if (name === 'hover') {
674-
this.hover = true;
675-
}
676672
let args = token.arguments.map(arg => {
677673
return this.compose_argument(arg, coords);
678674
});
@@ -784,7 +780,6 @@ class Rules {
784780
pattern: this.pattern,
785781
uniforms: this.uniforms,
786782
content: this.content,
787-
hover: this.hover,
788783
}
789784
}
790785

src/index.js

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ if (typeof customElements !== 'undefined') {
5555
animation.cancel();
5656
}
5757
this.animations = [];
58-
this.remove_hover();
5958
this.remove_uniform_mouse();
6059
}
6160

@@ -405,7 +404,7 @@ if (typeof customElements !== 'undefined') {
405404
let style_container = get_grid_styles(grid) + host + container;
406405
let style_cells = has_delay ? '' : cells;
407406

408-
const { uniforms, content, hover } = compiled;
407+
const { uniforms, content } = compiled;
409408

410409
let replace = this.replace(compiled);
411410

@@ -428,11 +427,6 @@ if (typeof customElements !== 'undefined') {
428427
this.set_content('.style-cells', replace(cells));
429428
}
430429

431-
if (hover) {
432-
this.register_hover();
433-
} else {
434-
this.remove_hover();
435-
}
436430
if (uniforms.time) {
437431
this.register_uniform_time();
438432
}
@@ -448,35 +442,6 @@ if (typeof customElements !== 'undefined') {
448442
}
449443
}
450444

451-
register_hover() {
452-
if (!this.hover_callback) {
453-
this.hover_callback = e => {
454-
e.target.classList.add('hover');
455-
this.hovered_element = e.target;
456-
}
457-
}
458-
if (!this.hover_out_callback) {
459-
this.hover_out_callback = e => {
460-
if (this.hovered_element) {
461-
this.hovered_element.classList.remove('hover');
462-
}
463-
}
464-
}
465-
this.doodle.addEventListener('pointerover', this.hover_callback);
466-
this.doodle.addEventListener('pointerout', this.hover_out_callback);
467-
}
468-
469-
remove_hover() {
470-
if (this.hover_callback) {
471-
this.doodle.removeEventListener('pointerover', this.hover_callback);
472-
this.doodle.removeEventListener('pointerout', this.hover_out_callback);
473-
let el = this.doodle.querySelector('.hover');
474-
if (el) {
475-
el.classList.remove('hover');
476-
}
477-
}
478-
}
479-
480445
register_uniform_mouse(uniforms) {
481446
if (!this.uniform_mouse_callback) {
482447
let { uniform_mousex, uniform_mousey } = Uniforms;

src/selector.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ function nth(input, curr, max) {
1919
function get_selector(offset) {
2020
let selector = '';
2121
if (offset == 0) {
22-
selector = '$.hover';
22+
selector = '$:hover';
2323
}
2424
else if (offset > 0) {
25-
selector = `$.hover ${'+*'.repeat(offset)}`;
25+
selector = `$:hover ${'+*'.repeat(offset)}`;
2626
}
2727
else {
28-
selector = `:has(+ ${'*+'.repeat(Math.abs(offset + 1))} $.hover)`;
28+
selector = `:has(+ ${'*+'.repeat(Math.abs(offset + 1))} $:hover)`;
2929
}
3030
return selector;
3131
}

0 commit comments

Comments
 (0)