Skip to content

Commit e71d79e

Browse files
committed
3.0.0
1 parent ed51a31 commit e71d79e

File tree

2 files changed

+86
-64
lines changed

2 files changed

+86
-64
lines changed

README.md

Lines changed: 72 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Below is a list of these methods and properties. Then you can see [an example im
2020
---
2121

2222
- [`constructor()`](#constructor)
23+
- [`defaults`](#defaults)
24+
- [`defaultSettings`](#defaultsettings)
25+
- [`defaultProps`](#defaultprops)
2326
- [`_setup()`](#_setup)
2427
- [`_beforeInitialize()`](#_beforeinitialize)
2528
- [`_afterInitialize()`](#_afterinitialize)
2629
- [`initialize()`](#initialize)
27-
- [`defaults`](#defaults)
28-
- [`defaultSettings`](#defaultsettings)
29-
- [`defaultProps`](#defaultprops)
3030

3131

3232
### `constructor()`
@@ -35,6 +35,25 @@ Here we describe the future instances.:
3535
- get data from arguments
3636
- declare instance properties
3737

38+
### `defaults`
39+
40+
> since v3.0.0 property renamed to `defaultSettings`
41+
42+
### `defaultSettings`
43+
44+
_`public`_
45+
_**`since v3.0.0`**_
46+
47+
A getter that returns an object with default options, settings, or configuration for your plugin.
48+
49+
### `defaultProps`
50+
51+
_`public`_
52+
_**`since v3.0.0`**_
53+
54+
A getter that returns an object with predefined props.
55+
Most often this is a list of options that are not included in the list of certain options of your plugin. But you need them for individual processing your options, settings, data, etc.
56+
3857

3958
### `_setup()`
4059

@@ -63,25 +82,6 @@ _`public`_
6382

6483
Directly launch your plugin.
6584

66-
### `defaults`
67-
68-
> since v3.0.0 property renamed to `defaultSettings`
69-
70-
### `defaultSettings`
71-
72-
_`public`_
73-
_**`since v3.0.0`**_
74-
75-
A getter that returns an object with default options, settings, or configuration for your plugin.
76-
77-
### `defaultProps`
78-
79-
_`public`_
80-
_**`since v3.0.0`**_
81-
82-
A getter that returns an object with predefined props.
83-
Most often this is a list of options that are not included in the list of certain options of your plugin. But you need them for individual processing your options, settings, data, etc.
84-
8585
---
8686

8787
## Usage example
@@ -113,70 +113,86 @@ export class SomeJqueryPluginAbstract extends WebPluginInterface {
113113
this.readyCssClass = 'is-ready';
114114
this.initializedCssClass = 'is-initialized';
115115
}
116+
117+
/**
118+
* @type {Object}
119+
*/
120+
get defaultSettings () {
121+
return {
122+
// an example of some options of your plugin
123+
autoplay: true,
124+
speed: 500
125+
}
126+
}
116127

117-
/** @protected */
128+
/**
129+
* @type {Object}
130+
*/
131+
get defaultProps () {
132+
return {
133+
// an example of options that is native for your plugin
134+
stopAutoPlayIfOutView: true
135+
}
136+
}
137+
138+
/**
139+
* @protected
140+
*/
118141
_setup () {
119142
this.props = $.extends({}, this.defaultProps, this.customProps);
120143
this.settings = $.extends({}, this.defaultSettings, this.customSettings);
121144

122145
// props example
123146
if (this.props.stopAutoPlayIfOutView) {
124-
this.settings.autoplay = this.detectIfInView();
147+
this.settings.autoplay = this.detectIfInView;
125148
}
126149
}
127150

128-
/** @protected */
151+
/**
152+
* @protected
153+
*/
129154
_beforeInitialize () {
130155
this.$container.addClass(this.readyCssClass);
131156
}
132157

133-
/** @protected */
158+
/**
159+
* @protected
160+
*/
134161
_afterInitialize () {
135162
this.$container.addClass(this.initializedCssClass);
136163

137164
// props example
138165
if (this.props.stopAutoPlayIfOutView) {
139-
this.autoplayInViewObserve()
166+
this._autoplayInViewObserve();
140167
}
141168
}
142169

143-
/** @public */
144170
initialize () {
145-
this._setup();
146-
this._beforeInitialize();
171+
this._setup();
172+
this._beforeInitialize();
173+
174+
// fire up
147175
this.$container.someJqueryPlugin(this.settings);
176+
148177
this._afterInitialize();
149178
}
150-
151-
/**
152-
* @public
153-
* @returns Object
154-
*/
155-
get defaultSettings () {
156-
return {
157-
// an example of some options of your plugin
158-
autoplay: true,
159-
speed: 500
160-
}
161-
}
162-
163-
get defaultProps () {
164-
return {
165-
// an example of options that is native for your plugin
166-
stopAutoPlayIfOutView: true
167-
}
168-
}
169179

170-
// ------------------------------
171-
// Custom extend implemented interface
172-
// ------------------------------
180+
// ------------------------------
181+
// Custom extend implemented interface
182+
// ------------------------------
173183

174-
detectIfInView () {
175-
// your code
184+
/**
185+
* @type {boolean}
186+
*/
187+
get detectIfInView () {
188+
// your code
176189
}
177190

178-
autoplayInViewObserve () {
179-
// your code
191+
/**
192+
* @protected
193+
*/
194+
_autoplayInViewObserve () {
195+
// your code
180196
}
181197
}
182198
```

index.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,20 @@ export class WebPluginInterface {
1414
// code
1515
}
1616

17+
/**
18+
* @type {Object}
19+
*/
20+
get defaultSettings () {
21+
return {};
22+
}
23+
24+
/**
25+
* @type {Object}
26+
*/
27+
get defaultProps () {
28+
return {};
29+
}
30+
1731
/**
1832
* @protected
1933
*/
@@ -38,12 +52,4 @@ export class WebPluginInterface {
3852
initialize () {
3953
// code
4054
}
41-
42-
get defaultSettings () {
43-
return {};
44-
}
45-
46-
get defaultProps () {
47-
return {};
48-
}
4955
}

0 commit comments

Comments
 (0)