Skip to content

Commit

Permalink
Clean-up and es6-ify init function.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonahvsweb committed Sep 30, 2017
1 parent 15c501d commit 87c0145
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 23 deletions.
14 changes: 9 additions & 5 deletions dist/touchpoint-es5.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/touchpoint-es5.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/touchpoint-es5.min.js

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

15 changes: 8 additions & 7 deletions dist/touchpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ var TouchPoint;
isSafari: !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),
clickTap: ('ontouchstart' in window ? 'touchstart' : 'click'),
el: 'div',
dom: window,
dom: '',
styleEl: '',
color: '#FFF',
opacity: 0.8,
Expand All @@ -27,16 +27,17 @@ var TouchPoint;
tp: '',
z: 9999,

init: function(el) {
TouchPoint.dom = el;
init(dom = 'body') {

TouchPoint
this.dom = document.querySelector(dom);

this
.createCss('.tp-init',
'position: relative; width: ' + TouchPoint.size + 'px; height: ' + TouchPoint.size + 'px; background-color: ' + TouchPoint.color + '; opacity: ' + TouchPoint.opacity + '; border-radius: 20px; -ms-transform: scale(0.5); -webkit-transform: scale(0.5); -moz-transform: scale(0.5); -o-transform: scale(0.5); transform: scale(0.5); -ms-transition: all 0.5s ease-out; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; transition: all 0.5s ease-out; z-index: ' + TouchPoint.z + ';')
`position: relative; width: ${ this.size }px; height: ${ this.size }px; background-color: ${ this.color }; opacity: ${ this.color }; border-radius: 20px; -ms-transform: scale(0.5); -webkit-transform: scale(0.5); -moz-transform: scale(0.5); -o-transform: scale(0.5); transform: scale(0.5); -ms-transition: all 0.5s ease-out; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; transition: all 0.5s ease-out; z-index: ${ this.z };`)
.createCss('.tp-anim',
'-ms-transform: scale(' + TouchPoint.scale + '); -webkit-transform: scale(' + TouchPoint.scale + '); -moz-transform: scale(' + TouchPoint.scale + '); -o-transform: scale(' + TouchPoint.scale + '); transform: scale(' + TouchPoint.scale + '); opacity: 0;'
`-ms-transform: scale(${ this.scale }); -webkit-transform: scale(${ this.scale }); -moz-transform: scale(${ this.scale }); -o-transform: scale(${ this.scale }); transform: scale(${ this.scale }); opacity: 0;`
);
TouchPoint.dom.addEventListener(TouchPoint.clickTap, TouchPoint.create, false);
this.dom.addEventListener(this.clickTap, this.create, false);
},

create: function(e) {
Expand Down
3 changes: 1 addition & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
<div class="container">
<section id="iphone-x" class="silver">
<div class="wrap">
<h1 class="new">iPhone X</h1>
<div class="marvel-device iphone-x">
<div class="notch">
<div class="camera"></div>
Expand All @@ -50,7 +49,7 @@ <h1 class="new">iPhone X</h1>
<script>
(function () {
TouchPoint.color = 'red';
TouchPoint.init(window);
TouchPoint.init();
})();
</script>
<script>
Expand Down
15 changes: 8 additions & 7 deletions src/touchpoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ var TouchPoint;
isSafari: !!navigator.userAgent.match(/Version\/[\d\.]+.*Safari/),
clickTap: ('ontouchstart' in window ? 'touchstart' : 'click'),
el: 'div',
dom: window,
dom: '',
styleEl: '',
color: '#FFF',
opacity: 0.8,
Expand All @@ -18,16 +18,17 @@ var TouchPoint;
tp: '',
z: 9999,

init: function(el) {
TouchPoint.dom = el;
init(dom = 'body') {

TouchPoint
this.dom = document.querySelector(dom);

this
.createCss('.tp-init',
'position: relative; width: ' + TouchPoint.size + 'px; height: ' + TouchPoint.size + 'px; background-color: ' + TouchPoint.color + '; opacity: ' + TouchPoint.opacity + '; border-radius: 20px; -ms-transform: scale(0.5); -webkit-transform: scale(0.5); -moz-transform: scale(0.5); -o-transform: scale(0.5); transform: scale(0.5); -ms-transition: all 0.5s ease-out; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; transition: all 0.5s ease-out; z-index: ' + TouchPoint.z + ';')
`position: relative; width: ${ this.size }px; height: ${ this.size }px; background-color: ${ this.color }; opacity: ${ this.color }; border-radius: 20px; -ms-transform: scale(0.5); -webkit-transform: scale(0.5); -moz-transform: scale(0.5); -o-transform: scale(0.5); transform: scale(0.5); -ms-transition: all 0.5s ease-out; -webkit-transition: all 0.5s ease-out; -moz-transition: all 0.5s ease-out; -o-transition: all 0.5s ease-out; transition: all 0.5s ease-out; z-index: ${ this.z };`)
.createCss('.tp-anim',
'-ms-transform: scale(' + TouchPoint.scale + '); -webkit-transform: scale(' + TouchPoint.scale + '); -moz-transform: scale(' + TouchPoint.scale + '); -o-transform: scale(' + TouchPoint.scale + '); transform: scale(' + TouchPoint.scale + '); opacity: 0;'
`-ms-transform: scale(${ this.scale }); -webkit-transform: scale(${ this.scale }); -moz-transform: scale(${ this.scale }); -o-transform: scale(${ this.scale }); transform: scale(${ this.scale }); opacity: 0;`
);
TouchPoint.dom.addEventListener(TouchPoint.clickTap, TouchPoint.create, false);
this.dom.addEventListener(this.clickTap, this.create, false);
},

create: function(e) {
Expand Down

0 comments on commit 87c0145

Please sign in to comment.