Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

angular-sticky-table-header

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-sticky-table-header - npm Package Compare versions

Comparing version 0.2.2 to 0.2.8

2

bower.json
{
"name": "angular-sticky-table-header",
"version": "0.2.2",
"version": "0.2.8",
"description": "Sticky headers for tables",

@@ -5,0 +5,0 @@ "main": "dist/angular-sticky-table-header.js",

@@ -72,5 +72,5 @@ angular.module('watchDom', []).constant('watchDomOptions', {

setClonedCellWidths: ifClone(function () {
var thClones = scope.clone.find('th');
angular.forEach(element.find('th'), function (th, n) {
$(thClones[n]).css('width', $(th).css('width'));
var clones = scope.clone.find('th'), ths = element.find('th');
angular.forEach(clones, function (clone, n) {
angular.element(clone).css('width', angular.element(ths[n]).css('width'));
});

@@ -81,7 +81,12 @@ }),

left: scope.offset.left,
right: scope.offset.right
width: scope.offset.width
});
}),
setOffset: function () {
scope.offset = angular.element(scope.tr).offset();
var offset = angular.element(scope.tr).offset();
scope.offset = {
width: element[0].getBoundingClientRect().width,
left: offset.left,
top: offset.top
};
},

@@ -102,8 +107,10 @@ setStuck: function (bool) {

checkScroll: ifClone(function () {
var scroll = $window.scrollY;
if (!scope.stuck && scroll >= scope.offset.top) {
var scrollY = $window.scrollY;
if (!scope.stuck && scrollY >= scope.offset.top) {
scope.setClonedCellWidths();
scope.setStuck(true);
} else if (scope.stuck && scroll < scope.offset.top) {
} else if (scope.stuck && scrollY < scope.offset.top) {
scope.setStuck(false);
} else if ($window.scrollX) {
scope.clone.css('left', scope.offset.left - $window.scrollX);
}

@@ -116,4 +123,4 @@ }),

$timeout(function () {
scope.sizeClone();
scope.checkScroll();
scope.setClonedCellWidths();
});

@@ -132,4 +139,4 @@ },

scope.windowEvents = {
scroll: _.debounce(scope.checkScroll.bind(scope), options.interval),
resize: _.debounce(scope.setClonedCellWidths.bind(scope), options.interval)
scroll: scope.checkScroll,
resize: scope.sizeClone
};

@@ -136,0 +143,0 @@ angular.element($window).on(scope.windowEvents);

{
"name": "angular-sticky-table-header",
"version": "0.2.2",
"version": "0.2.8",
"description": "Sticky headers for tables",

@@ -5,0 +5,0 @@ "main": "dist/angular-sticky-table-header.js",

@@ -84,6 +84,9 @@ angular

var thClones = scope.clone.find('th');
var clones = scope.clone.find('th'),
ths = element.find('th');
angular.forEach(element.find('th'), function(th, n) {
$(thClones[n]).css('width', $(th).css('width'));
angular.forEach(clones, function(clone, n) {
angular
.element(clone)
.css('width', angular.element(ths[n]).css('width'));
});

@@ -97,3 +100,3 @@

left: scope.offset.left,
right: scope.offset.right
width: scope.offset.width
});

@@ -105,4 +108,10 @@

scope.offset = angular.element(scope.tr).offset();
var offset = angular.element(scope.tr).offset();
scope.offset = {
width: element[0].getBoundingClientRect().width,
left: offset.left,
top: offset.top
};
},

@@ -134,9 +143,13 @@

var scroll = $window.scrollY;
var scrollY = $window.scrollY;
if (!scope.stuck && scroll >= scope.offset.top) {
if (!scope.stuck && scrollY >= scope.offset.top) {
scope.setClonedCellWidths();
scope.setStuck(true);
} else if (scope.stuck && scroll < scope.offset.top) {
} else if (scope.stuck && scrollY < scope.offset.top) {
scope.setStuck(false);
} else if ($window.scrollX) {
scope.clone.css('left', scope.offset.left - $window.scrollX);
}

@@ -159,4 +172,4 @@

$timeout(function(){
scope.sizeClone();
scope.checkScroll();
scope.setClonedCellWidths();
});

@@ -184,4 +197,4 @@

scope.windowEvents = {
scroll: _.debounce(scope.checkScroll.bind(scope), options.interval),
resize: _.debounce(scope.setClonedCellWidths.bind(scope), options.interval)
scroll: scope.checkScroll,
resize: scope.sizeClone
};

@@ -188,0 +201,0 @@

@@ -118,3 +118,3 @@ // Generated by CoffeeScript 1.7.1

describe('#setCloneGutter', function() {
return it('should set the <th> clone\'s left and right CSS equal to scope.offset', function() {
return it('should set the <th> clone\'s left and width CSS equal to scope.offset', function() {
this.scope.clone = {

@@ -125,3 +125,3 @@ css: function() {}

left: 1,
right: 2
width: 2
};

@@ -134,13 +134,26 @@ spyOn(this.scope.clone, 'css');

describe('#setOffset', function() {
it('should call getOffset on the first <tr>', function() {
spyOn(($()).__proto__, 'offset');
this.scope.setOffset();
return expect(($()).__proto__.offset).toHaveBeenCalled();
});
return it('should set scope.offset equal to the value returned by getBoundingClientRect', function() {
beforeEach(function() {
spyOn(this.element[0], 'getBoundingClientRect').andReturn({
width: 'bar',
top: 'zoo'
});
spyOn(($()).__proto__, 'offset').andReturn({
width: 'woo',
top: 'moo'
});
this.scope.offset = null;
spyOn(($()).__proto__, 'offset').andReturn('foo');
this.scope.setOffset();
return expect(this.scope.offset).toEqual('foo');
return this.scope.setOffset();
});
it('should call getBoundingClientRect on the first <tr>', function() {
return expect(this.element[0].getBoundingClientRect).toHaveBeenCalledWith();
});
it('should call $.offset on the first <tr>', function() {
return expect(($()).__proto__.offset).toHaveBeenCalledWith();
});
return it('should set scope.offset equal to the width returned by getBoundingClientRect and the top returned by $.offset', function() {
return expect(this.scope.offset).toEqual({
width: 'bar',
top: 'moo'
});
});
});

@@ -253,9 +266,9 @@ describe('#setStuck', function() {

describe('#rowsChanged', function() {
return it('should call #checkScroll and #setClonedCellWidths after a $timeout', inject(function($timeout) {
return it('should call #checkScroll and #sizeClone after a $timeout', inject(function($timeout) {
spyOn(this.scope, 'checkScroll');
spyOn(this.scope, 'setClonedCellWidths');
spyOn(this.scope, 'sizeClone');
this.scope.rowsChanged();
$timeout.flush();
expect(this.scope.checkScroll).toHaveBeenCalled();
return expect(this.scope.setClonedCellWidths).toHaveBeenCalled();
return expect(this.scope.sizeClone).toHaveBeenCalled();
}));

@@ -262,0 +275,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc