Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
martrapp committed Jan 26, 2025
1 parent 7aebcf1 commit 48a5cbc
Show file tree
Hide file tree
Showing 10 changed files with 12 additions and 97 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"files": [
"lib/*.js",
"lib/*.d.ts",
"lib/bundled/*.js"
"lib/bundled/*.js",
"src/*.ts"
],
"exports": {
".": "./lib/index.js",
Expand Down
9 changes: 0 additions & 9 deletions src/before-and-after.ts

This file was deleted.

5 changes: 3 additions & 2 deletions src/bundled/declarative-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { setSelectedViewTransitionNames } from '../set-view-transition-names';
The function sets up eventListeners that look for script elements with a `data-vtbag-decl` attribute and uses its value to set view transition names. The value is interpreted as a semicolon separated list of `<selector> '=' <prefix>` pairs. Those pairs are then used to set view transition names.
See setSelectedViewTransitionNames() for additional information.
See setSelectedViewTransitionNames() for additional information. When `~=` is used instead of `=`, setSelectedViewTransitionNames() is called with `weak = true`.
Do not use '=' or ';' in <selector> or <prefix> values
Expand Down Expand Up @@ -32,7 +32,8 @@ function set(what: 'new' | 'old') {
const weak = selector.endsWith('~');
weak && (selector = selector.slice(0, -1));
setSelectedViewTransitionNames(selector.trim(), prefix.trim(), !weak);
}});
}
});
});
};
}
Expand Down
File renamed without changes.
38 changes: 0 additions & 38 deletions src/drawer.ts

This file was deleted.

2 changes: 0 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ export {
setOldPageViewTransitionNames,
setNewPageViewTransitionNames,
} from './set-view-transition-names';
export { mayStartViewTransition } from './may-start-view-transition';
export { beforeAndAfter } from './before-and-after';
14 changes: 0 additions & 14 deletions src/may-start-view-transition.ts

This file was deleted.

11 changes: 0 additions & 11 deletions src/navigation.ts

This file was deleted.

10 changes: 7 additions & 3 deletions src/set-view-transition-names.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@ Otherwise the `elements` are named with the `prefix` with an appended index star
If `force` is true, the names are always set, otherwise only if they are not already set.
If the prefix string ends with a '~', the character is replaced by a '-' and the names are assigned in random order.
*/
export function setGivenViewTransitionNames(elements: HTMLElement[], prefix: string, force = false) {
export function setGivenViewTransitionNames(
elements: HTMLElement[],
prefix: string,
force = false
) {
if (prefix[prefix.length - 1] === '~') {
prefix = prefix.slice(0, -1) + '-';
shuffle(elements);
}
elements.forEach((element, idx, array) => {
force && (element.style.viewTransitionName = `${prefix}${array.length > 1 ? idx : ''}`)
|| (element.style.viewTransitionName ||= `${prefix}${array.length > 1 ? idx : ''}`);
(force && (element.style.viewTransitionName = `${prefix}${array.length > 1 ? idx : ''}`)) ||
(element.style.viewTransitionName ||= `${prefix}${array.length > 1 ? idx : ''}`);
});
}

Expand Down
17 changes: 0 additions & 17 deletions src/types.ts

This file was deleted.

0 comments on commit 48a5cbc

Please sign in to comment.