blink-element
Advanced tools
Comparing version 1.0.0 to 1.0.1
104
lib/blink.js
/** | ||
* | ||
* @name blink-element | ||
* @version 1.0.0 | ||
* @author Tiaan du Plessis (tiaanduplessis@hotmail.com) | ||
* @version 1.0.1 | ||
* @author Tiaan du Plessis | ||
* @license MIT | ||
*/ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.blink = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
'use strict'; | ||
(function (f) { if (typeof exports === 'object' && typeof module !== 'undefined') { module.exports = f() } else if (typeof define === 'function' && define.amd) { define([], f) } else { var g; if (typeof window !== 'undefined') { g = window } else if (typeof global !== 'undefined') { g = global } else if (typeof self !== 'undefined') { g = self } else { g = this }g.blink = f() } })(function () { | ||
var define, module, exports; return (function e (t, n, r) { function s (o, u) { if (!n[o]) { if (!t[o]) { var a = typeof require === 'function' && require; if (!u && a) return a(o, !0); if (i) return i(o, !0); var f = new Error("Cannot find module '" + o + "'"); throw f.code = 'MODULE_NOT_FOUND', f } var l = n[o] = {exports: {}}; t[o][0].call(l.exports, function (e) { var n = t[o][1][e]; return s(n || e) }, l, l.exports, e, t, n, r) } return n[o].exports } var i = typeof require === 'function' && require; for (var o = 0; o < r.length; o++)s(r[o]); return s })({1: [function (require, module, exports) { | ||
'use strict' | ||
@@ -16,34 +17,34 @@ /** | ||
module.exports = function blink() { | ||
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { speed: 0.01 }; | ||
module.exports = function blink () { | ||
var args = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { speed: 0.01 } | ||
if (!args.element) { | ||
throw new Error('No element provided'); | ||
} | ||
if (!args.element) { | ||
throw new Error('No element provided') | ||
} | ||
var isStopped = false; | ||
args.element.style.opacity = 1; | ||
var isStopped = false | ||
args.element.style.opacity = 1 | ||
var loop = function loop() { | ||
if (!isStopped) { | ||
fadeIn(args.element, args.speed, function () { | ||
fadeOut(args.element, args.speed, function () { | ||
return loop(); | ||
}); | ||
}); | ||
} | ||
}; | ||
var loop = function loop () { | ||
if (!isStopped) { | ||
fadeIn(args.element, args.speed, function () { | ||
fadeOut(args.element, args.speed, function () { | ||
return loop() | ||
}) | ||
}) | ||
} | ||
} | ||
loop(); | ||
loop() | ||
return { | ||
start: function start() { | ||
isStopped = false; | ||
loop(); | ||
}, | ||
stop: function stop() { | ||
isStopped = true; | ||
return { | ||
start: function start () { | ||
isStopped = false | ||
loop() | ||
}, | ||
stop: function stop () { | ||
isStopped = true | ||
} | ||
} | ||
} | ||
}; | ||
}; | ||
@@ -53,5 +54,5 @@ /** | ||
*/ | ||
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (cb) { | ||
window.setTimeout(cb, 1000 / 60); | ||
}; | ||
var raf = window.requestAnimationFrame || window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.msRequestAnimationFrame || function (cb) { | ||
window.setTimeout(cb, 1000 / 60) | ||
} | ||
@@ -61,10 +62,10 @@ /** | ||
*/ | ||
function fadeOut(elem, speed, cb) { | ||
elem.style.opacity = 1; | ||
var fade = function fade() { | ||
elem.style.opacity -= speed; | ||
elem.style.opacity < 0 ? cb() : raf(fade); | ||
}; | ||
fade(); | ||
} | ||
function fadeOut (elem, speed, cb) { | ||
elem.style.opacity = 1 | ||
var fade = function fade () { | ||
elem.style.opacity -= speed | ||
elem.style.opacity < 0 ? cb() : raf(fade) | ||
} | ||
fade() | ||
} | ||
@@ -74,12 +75,11 @@ /** | ||
*/ | ||
function fadeIn(elem, speed, cb) { | ||
elem.style.opacity = 0; | ||
var fade = function fade() { | ||
elem.style.opacity = parseFloat(elem.style.opacity) + speed; | ||
elem.style.opacity > 1 ? cb() : raf(fade); | ||
}; | ||
fade(); | ||
} | ||
},{}]},{},[1])(1) | ||
}); | ||
function fadeIn (elem, speed, cb) { | ||
elem.style.opacity = 0 | ||
var fade = function fade () { | ||
elem.style.opacity = parseFloat(elem.style.opacity) + speed | ||
elem.style.opacity > 1 ? cb() : raf(fade) | ||
} | ||
fade() | ||
} | ||
}, {}]}, {}, [1])(1) | ||
}) |
/** | ||
* | ||
* @name blink-element | ||
* @version 1.0.0 | ||
* @author Tiaan du Plessis (tiaanduplessis@hotmail.com) | ||
* @version 1.0.1 | ||
* @author Tiaan du Plessis | ||
* @license MIT | ||
@@ -7,0 +7,0 @@ */ |
{ | ||
"name": "blink-element", | ||
"version": "1.0.0", | ||
"description": "Simple module to make DOM element blink", | ||
"version": "1.0.1", | ||
"description": "For those times you wanna make a element blink using JS", | ||
"license": "MIT", | ||
@@ -16,8 +16,8 @@ "repository": { | ||
"bugs": "https://github.com/tiaanduplessis/blink-element/issues", | ||
"author": "Tiaan du Plessis (tiaanduplessis@hotmail.com)", | ||
"author": "Tiaan du Plessis", | ||
"scripts": { | ||
"start": "npm run build", | ||
"build": "npm run bundle; npm run uglify; npm run banner", | ||
"lint": "standard --verbose | snazzy", | ||
"lint:fix": "standard --fix --verbose | snazzy", | ||
"lint": "standard index.js", | ||
"lint:fix": "standard index.js --fix", | ||
"bundle": "browserify index.js --standalone blink > lib/blink.js -t [ babelify --presets [ es2015 ] ]", | ||
@@ -32,2 +32,3 @@ "uglify": "uglifyjs lib/blink.js --output lib/blink.min.js", | ||
"blinker", | ||
"blinky", | ||
"blink-element" | ||
@@ -37,13 +38,12 @@ ], | ||
"devDependencies": { | ||
"babel-preset-es2015": "^6.18.0", | ||
"babel-preset-es2015": "^6.24.0", | ||
"babelify": "^7.3.0", | ||
"bannerman": "^1.0.0", | ||
"browser-sync": "^2.18.5", | ||
"browserify": "^13.1.1", | ||
"browser-sync": "^2.18.8", | ||
"browserify": "^14.1.0", | ||
"cpy-cli": "^1.0.1", | ||
"gh-pages": "^0.12.0", | ||
"snazzy": "^5.0.0", | ||
"standard": "^8.6.0", | ||
"uglify-js": "^2.7.5" | ||
"standard": "^9.0.1", | ||
"uglify-js": "^2.8.12" | ||
} | ||
} |
@@ -1,22 +0,71 @@ | ||
<p align="center"> | ||
<a href="https://tiaanduplessis.github.io/blink-element/"><img width="75%" src="media/blink.gif" alt="Blink - Simple module to make DOM element blink"></a> | ||
</p> | ||
<h1 align="center">✨ blink-element</h1> | ||
<br> | ||
<div align="center"> | ||
<img width="100%" src="https://raw.githubusercontent.com/tiaanduplessis/blink-element/master/media/blink.gif" alt="Blink - For those times you wanna make a element blink using JS" /> | ||
</div> | ||
<br> | ||
<div align="center"> | ||
<a href="https://npmjs.org/package/blink-element"> | ||
<img src="https://img.shields.io/npm/v/blink-element.svg?style=flat-square" alt="Package version" /> | ||
</a> | ||
<a href="https://npmjs.org/package/blink-element"> | ||
<img src="https://img.shields.io/npm/dm/blink-element.svg?style=flat-square" alt="Downloads" /> | ||
</a> | ||
<a href="https://github.com/feross/standard"> | ||
<img src="https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square" alt="Standard" /> | ||
</a> | ||
<a href="https://travis-ci.org/tiaanduplessis/blink-element"> | ||
<img src="https://img.shields.io/travis/tiaanduplessis/blink-element.svg?style=flat-square" alt="Travis Build" /> | ||
</a> | ||
<a href="https://github.com/RichardLitt/standard-readme)"> | ||
<img src="https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square" alt="Standard Readme" /> | ||
</a> | ||
<a href="https://badge.fury.io/gh/tiaanduplessis%2Fblink-element"> | ||
<img src="https://badge.fury.io/gh/tiaanduplessis%2Fblink-element.svg?style=flat-square" alt="GitHub version" /> | ||
</a> | ||
<a href="https://dependencyci.com/github/tiaanduplessis/blink-element"> | ||
<img src="https://dependencyci.com/github/tiaanduplessis/blink-element/badge?style=flat-square" alt="Dependency CI" /> | ||
</a> | ||
<a href="https://github.com/tiaanduplessis/blink-element/blob/master/other/LICENSE"> | ||
<img src="https://img.shields.io/npm/l/blink-element.svg?style=flat-square" alt="License" /> | ||
</a> | ||
<a href="http://makeapullrequest.com"> | ||
<img src="https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square" alt="PRs" /> | ||
</a> | ||
<a href="https://www.paypal.me/tiaanduplessis/1"> | ||
<img src="https://img.shields.io/badge/$-support-green.svg?style=flat-square" alt="Donate" /> | ||
</a> | ||
</div> | ||
<br> | ||
<div align="center"> | ||
<a href="https://github.com/tiaanduplessis/blink-element/watchers"> | ||
<img src="https://img.shields.io/github/watchers/tiaanduplessis/blink-element.svg?style=social" alt="Github Watch Badge" /> | ||
</a> | ||
<a href="https://github.com/tiaanduplessis/blink-element/stargazers"> | ||
<img src="https://img.shields.io/github/stars/tiaanduplessis/blink-element.svg?style=social" alt="Github Star Badge" /> | ||
</a> | ||
<a href="https://twitter.com/intent/tweet?text=Check%20out%20blink-element!%20https://github.com/tiaanduplessis/blink-element%20%F0%9F%91%8D"> | ||
<img src="https://img.shields.io/twitter/url/https/github.com/tiaanduplessis/blink-element.svg?style=social" alt="Tweet" /> | ||
</a> | ||
</div> | ||
<br> | ||
<div align="center"> | ||
Built with ❤︎ by <a href="tiaanduplessis.co.za">Tiaan</a> and <a href="https://github.com/tiaanduplessis/blink-element/graphs/contributors">contributors</a> | ||
</div> | ||
<h2>Table of Contents</h2> | ||
<details> | ||
<summary>Table of Contents</summary> | ||
<li><a href="#about">about</a></li> | ||
<li><a href="#install">Install</a></li> | ||
<li><a href="#usage">Usage</a></li> | ||
<li><a href="#api">API</a></li> | ||
<li><a href="#contribute">Contribute</a></li> | ||
<li><a href="#license">License</a></li> | ||
</details> | ||
# blink-element | ||
[![Standard - JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard) | ||
[![Build Status](https://travis-ci.org/tiaanduplessis/blink-element.svg?branch=master)](https://travis-ci.org/tiaanduplessis/blink-element) | ||
[![standard-readme compliant](https://img.shields.io/badge/standard--readme-OK-green.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme) | ||
## About | ||
> Simple module to make DOM element blink | ||
A small module to make a DOM element blink using JS. | ||
## Table of Contents | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [API](#api) | ||
- [Contribute](#contribute) | ||
- [License](#license) | ||
## Install | ||
@@ -62,3 +111,3 @@ | ||
The `blink` function takes a single object as its argument with `element` and `speed` as its properties. | ||
The `blink` function takes a single object as its argument with `element` and `speed` as its properties. | ||
@@ -72,6 +121,7 @@ See [usage](#usage) for an example of how to call the function. | ||
Small note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. | ||
Note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification. | ||
## License | ||
Created with ♥ by [Tiaan](http://tiaanduplessis.co.za). Licensed under the MIT License. | ||
Licensed under the MIT License. | ||
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
11952
9
79
126
1