Skip to content

Commit

Permalink
Better modularize for renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
PRO-2684 committed Jul 30, 2024
1 parent 72c8653 commit c31d801
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
14 changes: 12 additions & 2 deletions modules/renderer/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,18 @@ function cssHelper(path, css, enabled, meta) {
}
}

/**
* Remove all styles injected by transitio.
*/
function removeAllStyles() {
const styles = document.querySelectorAll(`style[${styleDataAttr}]`);
styles.forEach((style) => {
style.remove();
});
}

export {
styleDataAttr,
getSelectDefaultValue,
cssHelper
cssHelper,
removeAllStyles
};
9 changes: 2 additions & 7 deletions renderer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
import { styleDataAttr, cssHelper } from "./modules/renderer/css.js";
import { cssHelper, removeAllStyles } from "./modules/renderer/css.js";
import { initTransitioSettings, transitioSettingsUpdateStyle, transitioSettingsResetStyle } from "./modules/renderer/settings.js";

transitio.onUpdateStyle((event, args) => {
cssHelper(args.path, args.css, args.enabled, args.meta);
});
transitio.onResetStyle(() => {
const styles = document.querySelectorAll(`style[${styleDataAttr}]`);
styles.forEach((style) => {
style.remove();
});
});
transitio.onResetStyle(removeAllStyles);
transitio.rendererReady();

/**
Expand Down

0 comments on commit c31d801

Please sign in to comment.