Skip to content

Commit

Permalink
fix(core): improved internal styles mechanics (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
roman-rr committed Oct 29, 2022
1 parent 56049ae commit 23af735
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 51 deletions.
4 changes: 2 additions & 2 deletions dist/core/index.js

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions dist/cupertino-pane.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
* Released under the MIT License
*
* Released on: October 20, 2022
* Released on: October 29, 2022
*/

/******************************************************************************
Expand Down Expand Up @@ -1891,6 +1891,9 @@ class CupertinoPane {
modules.forEach((module) => this.modules[this.getModuleRef(module.name)] = new module(this));
}
drawBaseElements() {
// Style element on head
this.styleEl = document.createElement('style');
this.styleEl.id = `cupertino-pane-${(Math.random() + 1).toString(36).substring(7)}`;
// Parent
this.parentEl = this.settings.parentElement;
// Wrapper
Expand Down Expand Up @@ -2003,7 +2006,8 @@ class CupertinoPane {
this.contentEl.style.transition = `opacity ${this.settings.animationDuration}ms ${this.settings.animationType} 0s`;
this.contentEl.style.overflowX = 'hidden';
// Inject internal CSS
this.addStyle(internalStyles);
this.styleEl.textContent = internalStyles.replace(/\s\s+/g, ' ');
document.head.prepend(this.styleEl);
// inject DOM
this.parentEl.appendChild(this.wrapperEl);
this.wrapperEl.appendChild(this.paneEl);
Expand Down Expand Up @@ -2161,17 +2165,7 @@ class CupertinoPane {
* @param {string} styleString
*/
addStyle(styleString) {
styleString = styleString.replace(/\s\s+/g, ' ');
if (!document.querySelector('#cupertino-panes-internal')) {
const style = document.createElement('style');
style.id = 'cupertino-panes-internal';
style.textContent = styleString;
document.head.prepend(style);
}
else {
const style = document.querySelector('#cupertino-panes-internal');
style.textContent += styleString;
}
this.styleEl.textContent += styleString.replace(/\s\s+/g, ' ');
}
;
getModuleRef(className) {
Expand Down Expand Up @@ -2328,6 +2322,7 @@ class CupertinoPane {
destroyResets() {
this.parentEl.appendChild(this.contentEl);
this.wrapperEl.remove();
this.styleEl.remove();
/****** Detach Events *******/
this.events.detachAllEvents();
// Reset vars
Expand Down
4 changes: 2 additions & 2 deletions dist/cupertino-pane.esm.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/cupertino-pane.esm.min.js.map

Large diffs are not rendered by default.

21 changes: 8 additions & 13 deletions dist/cupertino-pane.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/cupertino-pane.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/cupertino-pane.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/modules/backdrop.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/modules/fit-height.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/modules/follower.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 23af735

Please sign in to comment.