ng-snackbar.es6
Advanced tools
Comparing version 0.1.1 to 0.2.0
{ | ||
"name": "ng-snackbar.es6", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "Snackbar angular.js module in ES6.", | ||
"main": "src/index.js", | ||
"scripts": { | ||
"build": "./node_modules/webpack/bin/webpack.js", | ||
"watch": "./node_modules/webpack/bin/webpack.js --watch", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"start": "node server.js", | ||
"postinstall": "npm run build", | ||
"nodemon": "./node_modules/nodemon/bin/nodemon.js ./server.js", | ||
"watch": "./node_modules/webpack/bin/webpack.js --watch --progress", | ||
"build": "./node_modules/webpack/bin/webpack.js --progress", | ||
"dev": "./node_modules/concurrently/src/main.js \"npm run nodemon\" \"npm run watch\"" | ||
}, | ||
@@ -14,6 +17,14 @@ "author": "ohpyupi", | ||
"devDependencies": { | ||
"babel-core": "^6.24.1", | ||
"babel-loader": "^7.0.0", | ||
"@uirouter/react": "^0.5.0", | ||
"babel-core": "^6.25.0", | ||
"babel-loader": "^7.1.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"css-loader": "^0.28.1", | ||
"babel-preset-react": "^6.24.1", | ||
"concurrently": "^3.5.0", | ||
"express": "^4.15.3", | ||
"nodemon": "^1.11.0", | ||
"morgan": "^1.8.2", | ||
"react": "^15.6.1", | ||
"react-dom": "^15.6.1", | ||
"css-loader": "^0.28.4", | ||
"html-loader": "^0.4.5", | ||
@@ -23,3 +34,6 @@ "style-loader": "^0.17.0", | ||
"webpack": "^2.5.1" | ||
}, | ||
"dependencies": { | ||
"dokebi": "^1.3.8" | ||
} | ||
} |
@@ -16,7 +16,7 @@ # ng-snackbar.es6 | ||
*/ | ||
import uirouter from 'angular-ui-router'; | ||
import Snackbar from 'ng-snackbar.es6'; | ||
import angular from 'angular'; | ||
import uirouter from '@uirouter/angularjs'; | ||
angular.module('app', [uirouter]) | ||
.service('snackbar', Snackbar); | ||
... | ||
``` | ||
@@ -29,9 +29,12 @@ | ||
``` | ||
import Snackbar from 'ng-snackbar.es6'; | ||
export class HomeController { | ||
constructor(snackbar) { | ||
this.snackbar = snackbar; | ||
} | ||
testMethod() { | ||
this.snackbar.flash("Hello world!"); | ||
} | ||
constructor($state) { | ||
this.snackbar = new Snackbar($state); | ||
} | ||
fetchUserData() { | ||
... | ||
this.snackbar.flash("Successfully loaded a user data!"); | ||
} | ||
} | ||
@@ -38,0 +41,0 @@ ``` |
'use strict'; | ||
import './style.css'; | ||
import Animator from './utils/animator'; | ||
import './styles.css'; | ||
import Animator from 'dokebi/services/accelerator'; | ||
export default class ErrorService { | ||
constructor($state) { | ||
constructor($state, params={}) { | ||
'ngInject'; | ||
/* | ||
** @param {string} params.directionFrom "top" or "bottom" (default: bottom) | ||
** @param {number} params.xi (default: -24) | ||
** @param {number} params.xf (default: 12) | ||
**/ | ||
this.snackbar = null; | ||
@@ -11,5 +16,9 @@ this.content = null; | ||
this.closeBtn = null; | ||
this.$state = $state; | ||
this.directionFrom = params.directionFrom ? params.directionFrom : `bottom`; | ||
this.xi = params.xi ? params.xi : -24; | ||
this.xf = params.xf ? params.xf : 12; | ||
this.closeLabel = params.closeLabel ? params.closeLabel : `DISMISS`; | ||
this.duration = params.duration ? params.duration : .75; | ||
this.init(); | ||
this.handleEventListeners(); | ||
this.$state = $state; | ||
} | ||
@@ -19,4 +28,4 @@ flash(message='', ...args) { | ||
let body = document.getElementsByTagName('body')[0]; | ||
let bottomAnimator = new Animator(-24, 12, .75); | ||
let opacityAnimator = new Animator(0, 1, .75); | ||
let positionAnimator = new Animator(this.xi, this.xf, this.duration); | ||
let opacityAnimator = new Animator(0, 1, this.duration); | ||
body.appendChild(this.snackbar); | ||
@@ -26,7 +35,7 @@ let degree = 0; | ||
degree++; | ||
let x = degree/10; | ||
if (x > .75) return clearInterval(timer); | ||
let x = degree/(100*this.duration); | ||
if (x > this.duration) return clearInterval(timer); | ||
this.snackbar.style.opacity = opacityAnimator.square(x); | ||
this.snackbar.style.bottom = `${bottomAnimator.square(x)}px`; | ||
}, 30); | ||
this.snackbar.style[this.directionFrom] = `${positionAnimator.square(x)}px`; | ||
}, 1); | ||
if (args[0]) this.$state.go(args[0], args[1] ? args[1]: {}); | ||
@@ -36,9 +45,9 @@ } | ||
let body = document.getElementsByTagName('body')[0]; | ||
let bottomAnimator = new Animator(12, -24, .75); | ||
let opacityAnimator = new Animator(1, 0, .75); | ||
let positionAnimator = new Animator(this.xf, this.xi, this.duration); | ||
let opacityAnimator = new Animator(1, 0, this.duration); | ||
let degree = 0; | ||
let timer = setInterval(()=>{ | ||
degree++; | ||
let x = degree/10; | ||
if (x > .75) { | ||
let x = degree/(100*this.duration); | ||
if (x > this.duration) { | ||
clearInterval(timer); | ||
@@ -48,4 +57,4 @@ return body.removeChild(this.snackbar); | ||
this.snackbar.style.opacity = opacityAnimator.square(x); | ||
this.snackbar.style.bottom = `${bottomAnimator.square(x)}px`; | ||
}, 30); | ||
this.snackbar.style[this.directionFrom] = `${positionAnimator.square(x)}px`; | ||
}, 1); | ||
} | ||
@@ -57,3 +66,3 @@ init() { | ||
this.closeBtn = document.createElement('span'); | ||
this.closeBtn.innerHTML = 'DISMISS'; | ||
this.closeBtn.innerHTML = this.closeLabel; | ||
this.content.appendChild(this.message); | ||
@@ -66,2 +75,3 @@ this.content.appendChild(this.closeBtn); | ||
this.closeBtn.className += 'snackbar-close-btn'; | ||
this.handleEventListeners(); | ||
} | ||
@@ -68,0 +78,0 @@ handleEventListeners() { |
@@ -8,3 +8,3 @@ 'use strict'; | ||
entry: { | ||
main: './src/index.js', | ||
app: `./app/app.module.js`, | ||
}, | ||
@@ -29,3 +29,3 @@ output: { | ||
query: { | ||
presets: ['es2015'] | ||
presets: ['es2015', 'react'] | ||
} | ||
@@ -32,0 +32,0 @@ }, |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Install scripts
Supply chain riskInstall scripts are run when the package is installed. The majority of malware in npm is hidden in install scripts.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
13
2
51
9196
1
16
261
1
2
+ Addeddokebi@^1.3.8
+ Addedbuffer-equal-constant-time@1.0.1(transitive)
+ Addeddokebi@1.3.8(transitive)
+ Addedecdsa-sig-formatter@1.0.11(transitive)
+ Addedencoding@0.1.13(transitive)
+ Addedhoek@2.16.3(transitive)
+ Addediconv-lite@0.6.3(transitive)
+ Addedis-stream@1.1.0(transitive)
+ Addedisemail@1.2.0(transitive)
+ Addedjoi@6.10.1(transitive)
+ Addedjsonwebtoken@7.4.3(transitive)
+ Addedjwa@1.4.1(transitive)
+ Addedjws@3.2.2(transitive)
+ Addedlodash.once@4.1.1(transitive)
+ Addedmoment@2.30.1(transitive)
+ Addedms@2.1.3(transitive)
+ Addednode-fetch@1.7.3(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedtopo@1.1.0(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedxtend@4.0.2(transitive)