Skip to content

Commit df88893

Browse files
committed
1.0.0-alpha2
1 parent ac90448 commit df88893

30 files changed

Lines changed: 973 additions & 2021 deletions

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
**[>> Demo](https://mdbootstrap.com/docs/standard/#demo)**
1212

13-
<a href="https://npmcharts.com/compare/mdbootstrap?minimal=true"> <img src="https://img.shields.io/npm/dm/mdbootstrap.svg" alt="Downloads"></a><a href="https://github.com/mdbootstrap/bootstrap-material-design/blob/master/License.pdf"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a> <a href="https://cdnjs.com/libraries/mdbootstrap"> <img src="https://img.shields.io/cdnjs/v/mdbootstrap.svg" alt="cdnjs"></a> <a href="https://badge.fury.io/js/mdbootstrap"><img src="https://badge.fury.io/js/mdbootstrap.svg" alt="npm"></a> <a href="https://twitter.com/intent/tweet/?text=Thanks+@mdbootstrap+for+creating+amazing+and+free+Material+Design+for+Bootstrap+4+UI+KIT%20https://mdbootstrap.com/docs/jquery/&hashtags=javascript,code,webdesign,bootstrap"> <img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"></a>
13+
<a href="https://npmcharts.com/compare/mdbootstrap?minimal=true"> <img src="https://img.shields.io/npm/dm/mdbootstrap.svg" alt="Downloads"></a><a href="https://github.com/mdbootstrap/bootstrap-material-design/blob/master/License.pdf"><img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License"></a> <a href="https://twitter.com/intent/tweet/?text=Thanks+@mdbootstrap+for+creating+amazing+and+free+Material+Design+for+Bootstrap+4+UI+KIT%20https://mdbootstrap.com/docs/jquery/&hashtags=javascript,code,webdesign,bootstrap"> <img src="https://img.shields.io/twitter/url/http/shields.io.svg?style=social"></a>
1414
___
1515

1616
<table>
@@ -92,6 +92,4 @@ ___
9292

9393
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-loaders1.gif"></a>
9494

95-
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-loaders2.gif"></a>
96-
9795
<a href="https://mdbootstrap.com/docs/standard/" alt="Bootstrap 5" rel="dofollow"><img src="https://mdbootstrap.com/img/Marketing/campaigns/demo-mdb5.jpg"></a>

README.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
MDB5
2-
Version: FREE 1.0.0-alpha1
2+
Version: FREE 1.0.0-alpha2
33

44
Documentation:
55
https://mdbootstrap.com/docs/standard/

css/mdb.min.css

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

css/mdb.min.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@
2121
</head>
2222
<body>
2323
<!-- Start your project here-->
24-
<div style="height: 100vh; text-align: center; margin-top: 150px;">
25-
<img
26-
src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.png"
27-
style="width: 250px; height: 90px;"
28-
/>
29-
<h5>Thank you for using our product. We're glad you're with us.</h5>
30-
<p>MDB Team</p>
24+
<div class="container">
25+
<div class="d-flex justify-content-center align-items-center" style="height: 100vh;">
26+
<div class="text-center">
27+
<img
28+
src="https://mdbootstrap.com/img/logo/mdb-transparent-250px.png"
29+
style="width: 250px; height: 90px;"
30+
/>
31+
<h5 class="pt-3">Thank you for using our product. We're glad you're with us.</h5>
32+
<p class="pb-5">MDB Team</p>
33+
</div>
34+
</div>
3135
</div>
3236
<!-- End your project here-->
3337
</body>

js/mdb.min.js

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/mdb.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mdb-ui-kit",
3-
"version": "1.0.0-alpha1",
3+
"version": "1.0.0-alpha2",
44
"main": "js/mdb.min.js",
55
"repository": "https://github.com/mdbootstrap/mdb-ui-kit.git",
66
"author": "MDBootstrap",

src/js/free/animate.js

Lines changed: 50 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,34 +16,40 @@ const SELECTOR_EXPAND = '[data-toggle="animation"]';
1616

1717
const DefaultType = {
1818
animation: 'string',
19+
start: 'string',
20+
showOnLoad: 'boolean',
1921
onStart: '(null|function)',
2022
onEnd: '(null|function)',
2123
onHide: '(null|function)',
2224
onShow: '(null|function)',
23-
animateonscroll: '(boolean|string)',
25+
animateOnScroll: '(string)',
2426
windowHeight: 'number',
2527
offset: '(number|string)',
2628
delay: '(number|string)',
2729
duration: '(number|string)',
2830
reverse: 'boolean',
2931
interval: '(number|string)',
3032
repeat: '(number|boolean)',
33+
reset: 'boolean',
3134
};
3235

3336
const Default = {
3437
animation: 'fade',
38+
start: 'onClick',
39+
showOnLoad: true,
3540
onStart: null,
3641
onEnd: null,
3742
onHide: null,
3843
onShow: null,
39-
animateonscroll: false,
44+
animateOnScroll: 'once',
4045
windowHeight: 0,
4146
offset: 0,
4247
delay: 0,
4348
duration: 500,
4449
reverse: false,
4550
interval: 0,
4651
repeat: false,
52+
reset: false,
4753
};
4854

4955
/**
@@ -82,10 +88,22 @@ class Animate {
8288

8389
// Private
8490
_init() {
85-
if (this._options.animateonscroll) {
86-
this._bindScrollEvents();
87-
} else {
88-
this._bindClickEvents();
91+
switch (this._options.start) {
92+
case 'onHover':
93+
this._bindHoverEvents();
94+
break;
95+
case 'onLoad':
96+
this._startAnimation();
97+
break;
98+
case 'onScroll':
99+
this._bindScrollEvents();
100+
break;
101+
default:
102+
this._bindClickEvents();
103+
break;
104+
}
105+
this._bindTriggerOnEndCallback();
106+
if (this._options.reset) {
89107
this._bindResetAnimationAfterFinish();
90108
}
91109
}
@@ -128,7 +146,7 @@ class Animate {
128146
this._hideAnimateElement();
129147
break;
130148
case shouldBeVisible && !isElementVisible && this._repeatAnimateOnScroll:
131-
if (this._options.animateonscroll !== 'repeat') {
149+
if (this._options.animateOnScroll !== 'repeat') {
132150
this._repeatAnimateOnScroll = false;
133151
}
134152
this._callback(this._options.onShow);
@@ -146,12 +164,12 @@ class Animate {
146164
}
147165

148166
_addAnimatedClass() {
149-
Manipulator.addClass(this._animateElement, 'animated');
167+
Manipulator.addClass(this._animateElement, 'animation');
150168
Manipulator.addClass(this._animateElement, this._options.animation);
151169
}
152170

153171
_clearAnimationClass() {
154-
this._animateElement.classList.remove(this._options.animation, 'animated');
172+
this._animateElement.classList.remove(this._options.animation, 'animation');
155173
}
156174

157175
_startAnimation() {
@@ -207,7 +225,6 @@ class Animate {
207225

208226
_setAnimationInterval() {
209227
EventHandler.on(this._animateElement, 'animationend', () => {
210-
this._callback(this._options.onEnd);
211228
this._clearAnimationClass();
212229
setTimeout(() => {
213230
this._addAnimatedClass();
@@ -225,17 +242,23 @@ class Animate {
225242

226243
_bindResetAnimationAfterFinish() {
227244
EventHandler.on(this._animateElement, 'animationend', () => {
228-
this._callback(this._options.onEnd);
229245
this._clearAnimationClass();
230246
});
231247
}
232248

249+
_bindTriggerOnEndCallback() {
250+
EventHandler.on(this._animateElement, 'animationend', () => {
251+
this._callback(this._options.onEnd);
252+
});
253+
}
254+
233255
_bindScrollEvents() {
234-
const scrollPositionOnPageLoad = window.scrollY;
256+
if (!this._options.showOnLoad) {
257+
this._animateOnScroll();
258+
}
259+
235260
EventHandler.on(window, 'scroll', () => {
236-
if (scrollPositionOnPageLoad !== window.scrollY) {
237-
this._animateOnScroll();
238-
}
261+
this._animateOnScroll();
239262
});
240263
}
241264

@@ -245,6 +268,18 @@ class Animate {
245268
});
246269
}
247270

271+
_bindHoverEvents() {
272+
EventHandler.one(this._element, 'mouseenter', () => {
273+
this._startAnimation();
274+
});
275+
EventHandler.one(this._animateElement, 'animationend', () => {
276+
// wait after bind hoverEvents to prevent animation looping
277+
setTimeout(() => {
278+
this._bindHoverEvents();
279+
}, 100);
280+
});
281+
}
282+
248283
_callback(fn) {
249284
if (fn instanceof Function) {
250285
fn();

src/js/free/input.js

Lines changed: 56 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const NAME = 'input';
1414
const DATA_KEY = 'mdb.input';
1515
const CLASSNAME_WRAPPER = 'form-outline';
1616
const OUTLINE_INPUT = `.${CLASSNAME_WRAPPER} input`;
17+
const OUTLINE_TEXTAREA = `.${CLASSNAME_WRAPPER} textarea`;
1718

1819
/**
1920
* ------------------------------------------------------------------------
@@ -24,8 +25,12 @@ const OUTLINE_INPUT = `.${CLASSNAME_WRAPPER} input`;
2425
class Input {
2526
constructor(element) {
2627
this._element = element;
28+
this._label = null;
2729
this._labelWidth = 0;
30+
this._labelMarginLeft = 0;
31+
this._notchLeading = null;
2832
this._notchMiddle = null;
33+
this._notchTrailing = null;
2934

3035
if (this._element) {
3136
Data.setData(element, DATA_KEY, this);
@@ -39,9 +44,9 @@ class Input {
3944

4045
// Public
4146
init() {
42-
this._calculateLabelWidth();
47+
this._getLabelData();
4348
this._applyDivs();
44-
this._applyNotchWidth();
49+
this._applyNotch();
4550
this._applyActiveClass();
4651
}
4752

@@ -51,40 +56,67 @@ class Input {
5156
}
5257

5358
// Private
54-
_calculateLabelWidth() {
55-
const label = SelectorEngine.findOne('label.form-label', this._element);
56-
this._labelWidth = label.clientWidth * 0.8 + 8;
59+
_getLabelData() {
60+
this._label = SelectorEngine.findOne('label', this._element);
61+
if (this._label === null) return;
62+
this._getLabelWidth();
63+
64+
if (!this._element.classList.contains('input-group')) return;
65+
this._getLabelPositionInInputGroup();
66+
}
67+
68+
_getLabelWidth() {
69+
this._labelWidth = this._label.clientWidth * 0.8 + 8;
70+
}
71+
72+
_getLabelPositionInInputGroup() {
73+
const input =
74+
SelectorEngine.findOne('input', this._element) ||
75+
SelectorEngine.findOne('textarea', this._element);
76+
const prefix = SelectorEngine.prev(input, '.input-group-text')[0];
77+
if (prefix === undefined) return;
78+
this._labelMarginLeft = prefix.offsetWidth - 1;
5779
}
5880

5981
_applyDivs() {
6082
const notchWrapper = element('div');
6183
Manipulator.addClass(notchWrapper, 'form-notch');
62-
const notchLeading = element('div');
63-
Manipulator.addClass(notchLeading, 'form-notch-leading');
84+
this._notchLeading = element('div');
85+
Manipulator.addClass(this._notchLeading, 'form-notch-leading');
6486
this._notchMiddle = element('div');
6587
Manipulator.addClass(this._notchMiddle, 'form-notch-middle');
66-
const notchTrailing = element('div');
67-
Manipulator.addClass(notchTrailing, 'form-notch-trailing');
88+
this._notchTrailing = element('div');
89+
Manipulator.addClass(this._notchTrailing, 'form-notch-trailing');
6890

69-
notchWrapper.append(notchLeading);
91+
notchWrapper.append(this._notchLeading);
7092
notchWrapper.append(this._notchMiddle);
71-
notchWrapper.append(notchTrailing);
93+
notchWrapper.append(this._notchTrailing);
7294
this._element.append(notchWrapper);
7395
}
7496

75-
_applyNotchWidth() {
97+
_applyNotch() {
7698
this._notchMiddle.style.width = `${this._labelWidth}px`;
99+
this._notchLeading.style.width = `${this._labelMarginLeft + 9}px`;
100+
101+
if (this._label === null) return;
102+
this._label.style.marginLeft = `${this._labelMarginLeft}px`;
77103
}
78104

79105
_applyActiveClass(event) {
80-
const input = event ? event.target : SelectorEngine.findOne('input', this._element);
106+
const input = event
107+
? event.target
108+
: SelectorEngine.findOne('input', this._element) ||
109+
SelectorEngine.findOne('textarea', this._element);
81110
if (input.value !== '') {
82111
Manipulator.addClass(input, 'active');
83112
}
84113
}
85114

86115
_removeActiveClass(event) {
87-
const input = event ? event.target : SelectorEngine.findOne('input', this._element);
116+
const input = event
117+
? event.target
118+
: SelectorEngine.findOne('input', this._element) ||
119+
SelectorEngine.findOne('textarea', this._element);
88120
if (input.value === '') {
89121
input.classList.remove('active');
90122
}
@@ -101,15 +133,23 @@ class Input {
101133
instance._removeActiveClass(event);
102134
};
103135
}
136+
137+
static getInstance(element) {
138+
return Data.getData(element, DATA_KEY);
139+
}
104140
}
105141

106142
EventHandler.on(document, 'focus', OUTLINE_INPUT, Input.applyActiveClass(new Input()));
107143
EventHandler.on(document, 'input', OUTLINE_INPUT, Input.applyActiveClass(new Input()));
108144
EventHandler.on(document, 'blur', OUTLINE_INPUT, Input.removeActiveClass(new Input()));
109145

146+
EventHandler.on(document, 'focus', OUTLINE_TEXTAREA, Input.applyActiveClass(new Input()));
147+
EventHandler.on(document, 'input', OUTLINE_TEXTAREA, Input.applyActiveClass(new Input()));
148+
EventHandler.on(document, 'blur', OUTLINE_TEXTAREA, Input.removeActiveClass(new Input()));
149+
110150
// auto-init
111-
SelectorEngine.find(`.${CLASSNAME_WRAPPER}`).forEach((input) => {
112-
new Input(input).init();
151+
SelectorEngine.find(`.${CLASSNAME_WRAPPER}`).forEach((element) => {
152+
new Input(element).init();
113153
});
114154

115155
export default Input;

0 commit comments

Comments
 (0)