Skip to content

Commit

Permalink
Fixes issue #23 - Added a new method for setting the wrapperClass at …
Browse files Browse the repository at this point in the history
…any time.
  • Loading branch information
joelkravets committed Nov 29, 2017
1 parent 1f4ee86 commit 4333cec
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
7 changes: 7 additions & 0 deletions README.md
Expand Up @@ -94,6 +94,13 @@ Set the `position` of the info window. A valid Google Map instance must be assoc
- Parameter: `latLng`
- _[LatLng]_ or _[LatLngLiteral]_

#### setWrapperClass(wrapperClass)

Set the `wrapperClass` of the info window. This can be called at any time.

- Parameter: `wrapperClass`
- _string_

#### getWrapper()

Will return the DOM Element for the wrapper container of the info window.
Expand Down
25 changes: 16 additions & 9 deletions src/snazzy-info-window.js
Expand Up @@ -268,6 +268,20 @@ export default class SnazzyInfoWindow extends getGoogleClass() {
}
}

setWrapperClass(wrapperClass) {
if (this._html && this._html.wrapper) {
const w = this._html.wrapper;
w.className = `${_classPrefix}wrapper-${this._opts.placement}`;
if (this._opts.border) {
w.className += ` ${_classPrefix}has-border`;
}
if (wrapperClass) {
w.className += ` ${wrapperClass}`;
}
}
this._opts.wrapperClass = wrapperClass;
}

getWrapper() {
if (this._html) {
return this._html.wrapper;
Expand Down Expand Up @@ -453,15 +467,8 @@ export default class SnazzyInfoWindow extends getGoogleClass() {
this._html = {};

// 1. Create the wrapper
this._html.wrapper = newElement(
`wrapper-${this._opts.placement}`
);
if (this._opts.wrapperClass) {
this._html.wrapper.className += ` ${this._opts.wrapperClass}`;
}
if (this._opts.border) {
applyCss(this._html.wrapper, ['has-border']);
}
this._html.wrapper = newElement();
this.setWrapperClass(this._opts.wrapperClass);

// 2. Create the shadow
if (this._opts.shadow) {
Expand Down

0 comments on commit 4333cec

Please sign in to comment.