Comparing version 0.0.6 to 0.0.7
{ | ||
"name": "ngScrollTo", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/iameugenejo/ngScrollTo", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -1,2 +0,2 @@ | ||
// Version 0.0.5-fix | ||
// Version 0.0.7 | ||
// AngularJS simple hash-tag scroll alternative | ||
@@ -49,3 +49,3 @@ // this directive uses click event to scroll to the target element | ||
this.idOrName = function (idOrName, offset, focus) {//find element with the given id or name and scroll to the first element it finds | ||
var document = $window.document; | ||
var currentDocument = $window.document; | ||
@@ -61,5 +61,5 @@ if(!idOrName) {//move to top if idOrName is not provided | ||
//check if an element can be found with id attribute | ||
var el = document.getElementById(idOrName); | ||
var el = currentDocument.getElementById(idOrName); | ||
if(!el) {//check if an element can be found with name attribute if there is no such id | ||
el = document.getElementsByName(idOrName); | ||
el = currentDocument.getElementsByName(idOrName); | ||
@@ -88,4 +88,8 @@ if(el && el.length) | ||
if (offset) { | ||
var top = el.getBoundingClientRect().top + el.ownerDocument.body.scrollTop - offset; | ||
window.scrollTo(0, top); | ||
var currentDocument = el.ownerDocument; | ||
var currentWindow = currentDocument.defaultView || currentDocument.parentWindow; // parentWindow is for IE8- | ||
var currentScrollTop = currentWindow.pageYOffset || currentDocument.documentElement.scrollTop || currentDocument.body.scrollTop || 0; | ||
var scrollToY = el.getBoundingClientRect().top + currentScrollTop - offset; | ||
currentWindow.scrollTo(0, scrollToY); | ||
} | ||
@@ -92,0 +96,0 @@ else { |
{ | ||
"name": "ngscrollto", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"homepage": "https://github.com/iameugenejo/ngScrollTo", | ||
@@ -5,0 +5,0 @@ "authors": [ |
ngScrollTo | ||
========== | ||
[![NPM version](https://badge.fury.io/js/ngscrollto.svg)](https://badge.fury.io/js/ngscrollto) | ||
[![NPM downloads](https://img.shields.io/npm/dm/ngScrollTo.svg?style=flat)](https://www.npmjs.org/package/ngScrollTo) | ||
Simple AngularJS scroll-to directive | ||
fiddle : [http://jsfiddle.net/8Mtxc/208/](http://jsfiddle.net/8Mtxc/208/) | ||
fiddle : [http://jsfiddle.net/8Mtxc/230/](http://jsfiddle.net/8Mtxc/230/) | ||
@@ -30,3 +32,3 @@ ``` html | ||
###Custom action | ||
Example: [http://jsfiddle.net/8Mtxc/212/](http://jsfiddle.net/8Mtxc/212/) | ||
Example: [http://jsfiddle.net/8Mtxc/231/](http://jsfiddle.net/8Mtxc/231/) | ||
``` javascript | ||
@@ -44,5 +46,8 @@ | ||
``` | ||
Update 0.0.7 | ||
* Increase browser compatibility | ||
Update 0.0.6 | ||
* Remove jQuery dependency | ||
* unbind element on directive destroy | ||
* Unbind element on directive destroy | ||
@@ -49,0 +54,0 @@ Update 0.0.5 |
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
6862
115
65
0