Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,18 @@ Similar to `constrainToWindow` but for the target element's first scroll parent:

Additional class names to be added to the drop. These can be set to apply a theme (for example, [`drop-theme-arrows-bounce-dark`](https://github.com/HubSpot/drop/blob/master/css/drop-theme-arrows-bounce-dark.css)) and/or they can be set to apply custom styling to child elements of the drop.

#### `classSuffixOpen`

Class name suffix used when the drop is opened and removed when it should be hidden. By default it's `-open`.

#### `classSuffixOpenTransitionend`

Class name suffix used immediately when the drop is open. By default it's `-open-transitionend`.

#### `classSuffixAfterOpen`

Class name suffix used when the next event loop tick after the drop is opened. By default it's `-after-open`.

#### `remove`

Set to `true` if you'd like the drop element to be removed from the DOM when the drop is closed and recreated when it's opened.
Expand Down
23 changes: 13 additions & 10 deletions src/js/drop.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ function createContext(options={}) {
constrainToScrollParent: true,
constrainToWindow: true,
classes: '',
classSuffixOpen: '-open',
classSuffixOpenTransitionend: '-open-transitionend',
classSuffixAfterOpen: '-after-open',
remove: false,
openDelay: 0,
closeDelay: 50,
Expand Down Expand Up @@ -115,9 +118,9 @@ function createContext(options={}) {
}

if (anyOpen) {
addClass(document.body, `${ drop.classPrefix }-open`);
addClass(document.body, `${ drop.classPrefix }${ drop.classSuffixOpen }`);
} else {
removeClass(document.body, `${ drop.classPrefix }-open`);
removeClass(document.body, `${ drop.classPrefix }${ drop.classSuffixOpen }`);
}

};
Expand Down Expand Up @@ -353,7 +356,7 @@ function createContext(options={}) {

isOpened() {
if (this.drop) {
return hasClass(this.drop, `${ drop.classPrefix }-open`);
return hasClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpen }`);
}
}

Expand All @@ -379,12 +382,12 @@ function createContext(options={}) {
this.tether.enable();
}

addClass(this.drop, `${ drop.classPrefix }-open`);
addClass(this.drop, `${ drop.classPrefix }-open-transitionend`);
addClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpen }`);
addClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpenTransitionend }`);

setTimeout(() => {
if (this.drop) {
addClass(this.drop, `${ drop.classPrefix }-after-open`);
addClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixAfterOpen }`);
}
});

Expand All @@ -402,8 +405,8 @@ function createContext(options={}) {
return;
}

if (!hasClass(this.drop, `${ drop.classPrefix }-open`)) {
removeClass(this.drop, `${ drop.classPrefix }-open-transitionend`);
if (!hasClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpen }`)) {
removeClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpenTransitionend }`);
}
this.drop.removeEventListener(transitionEndEvent, this.transitionEndHandler);
}
Expand All @@ -430,8 +433,8 @@ function createContext(options={}) {
return;
}

removeClass(this.drop, `${ drop.classPrefix }-open`);
removeClass(this.drop, `${ drop.classPrefix }-after-open`);
removeClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixOpen }`);
removeClass(this.drop, `${ drop.classPrefix }${ drop.classSuffixAfterOpen }`);

this.drop.addEventListener(transitionEndEvent, this.transitionEndHandler);

Expand Down