New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

affixed

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

affixed - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

44

lib/index.js

@@ -9,7 +9,19 @@ 'use strict';

var _events = require('events');
var _events2 = _interopRequireDefault(_events);
var _lodash = require('lodash');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var affixed = function () {
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var affixed = function (_EventEmitter) {
_inherits(affixed, _EventEmitter);
function affixed() {

@@ -20,2 +32,7 @@ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];

// last event
var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(affixed).call(this));
_this.lastEvent = null;
// merge options

@@ -28,16 +45,17 @@ var DEFAULTS = {

};
this.options = Object.assign({}, DEFAULTS, options);
_this.options = Object.assign({}, DEFAULTS, options);
// create mirror if necessary
if (this.options.position === 'mirror') {
this.createMirror();
if (_this.options.position === 'mirror') {
_this.createMirror();
}
// retrieve the computer styles for the parent element
this.parentStyles = window.getComputedStyle(this.options.element.parentNode);
this.parentMarginOffset = parseInt(this.parentStyles.marginBottom, 10);
_this.parentStyles = window.getComputedStyle(_this.options.element.parentNode);
_this.parentMarginOffset = parseInt(_this.parentStyles.marginBottom, 10);
// register window scroll event
window.addEventListener('scroll', (0, _lodash.throttle)(this.onWindowScroll.bind(this), this.options.throttle));
window.addEventListener('scroll', (0, _lodash.throttle)(_this.onWindowScroll.bind(_this), _this.options.throttle));
return _this;
}
/**
* Implemented with rAF (https://developer.mozilla.org/en-US/docs/Web/Events/scroll)
* This callback is throttled by _.throttle
*/

@@ -53,2 +71,6 @@

if (this.lastY > this.options.offset) {
if (this.lastEvent !== 'affixed') {
this.emit('affixed', this);
this.lastEvent = 'affixed';
}
if (this.options.position === 'mirror') {

@@ -82,2 +104,6 @@ // display the mirror

} else {
if (this.lastEvent !== 'unaffixed') {
this.emit('unaffixed', this);
this.lastEvent = 'unaffixed';
}
// hide mirror

@@ -111,4 +137,4 @@ if (this.options.position === 'mirror') {

return affixed;
}();
}(_events2.default);
exports.default = affixed;
{
"name": "affixed",
"description": "Make your containers affixed",
"version": "0.2.1",
"version": "0.2.2",
"main": "lib/index.js",

@@ -6,0 +6,0 @@ "keywords": [

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