Make animation setting an attribute instead of a property

This commit is contained in:
John Factotum
2023-11-28 11:07:56 +08:00
parent 2ea63929c7
commit cbe9e0009c
2 changed files with 3 additions and 5 deletions
+1 -2
View File
@@ -172,9 +172,8 @@ The filter only applies to the book itself, leaving overlaid elements such as hi
### The Paginator ### The Paginator
There is a basic page transition effect that can be disabled by setting `.pageAnimation` to false.
The layout can be configured by setting the following attributes: The layout can be configured by setting the following attributes:
- `animated`: a [boolean attribute](https://developer.mozilla.org/en-US/docs/Glossary/Boolean/HTML). If present, adds a sliding transition effect.
- `flow`: either `paginated` or `scrolled`. - `flow`: either `paginated` or `scrolled`.
- `margin`: a CSS `<length>`. The unit must be `px`. The height of the header and footer. - `margin`: a CSS `<length>`. The unit must be `px`. The height of the header and footer.
- `gap`: a CSS `<percentage>`. The size of the space between columns, relative to page size. - `gap`: a CSS `<percentage>`. The size of the space between columns, relative to page size.
+2 -3
View File
@@ -390,7 +390,6 @@ export class Paginator extends HTMLElement {
#scrollBounds #scrollBounds
#touchState #touchState
#touchScrolled #touchScrolled
pageAnimation = true
constructor() { constructor() {
super() super()
this.#root.innerHTML = `<style> this.#root.innerHTML = `<style>
@@ -762,7 +761,7 @@ export class Paginator extends HTMLElement {
} }
// FIXME: vertical-rl only, not -lr // FIXME: vertical-rl only, not -lr
if (this.scrolled && this.#vertical) offset = -offset if (this.scrolled && this.#vertical) offset = -offset
if (reason === 'snap' || smooth && this.pageAnimation) return animate( if ((reason === 'snap' || smooth) && this.hasAttribute('animated')) return animate(
element[scrollProp], offset, 300, easeOutQuad, element[scrollProp], offset, 300, easeOutQuad,
x => element[scrollProp] = x, x => element[scrollProp] = x,
).then(() => { ).then(() => {
@@ -932,7 +931,7 @@ export class Paginator extends HTMLElement {
index: this.#adjacentIndex(dir), index: this.#adjacentIndex(dir),
anchor: prev ? () => 1 : () => 0, anchor: prev ? () => 1 : () => 0,
}) })
if (shouldGo || !this.pageAnimation) await wait(100) if (shouldGo || !this.hasAttribute('animated')) await wait(100)
this.#locked = false this.#locked = false
} }
prev(distance) { prev(distance) {