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

drive-in

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drive-in - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

lib/utils.js

143

lib/index.js
var Jvent = require('jvent'),
inherits = require('inherits'),
Timer = require('./timer'),
Playlist = require('./playlist');
Playlist = require('./playlist'),
Utils = require('./utils'),
getWidth = Utils.getWidth,
getHeight = Utils.getHeight,
setStyles = Utils.setStyles,
findPoster = Utils.findPoster,
createEl = Utils.createEl,
replaceChildren = Utils.replaceChildren;
function getWidth() {
if (self.innerHeight) {
return self.innerWidth;
}
if (document.documentElement && document.documentElement.clientWidth) {
return document.documentElement.clientWidth;
}
if (document.body) {
return document.body.clientWidth;
}
}
function getHeight() {
if (self.innerHeight) {
return self.innerHeight;
}
if (document.documentElement && document.documentElement.clientHeight) {
return document.documentElement.clientHeight;
}
if (document.body) {
return document.body.clientHeight;
}
}
function setStyles(el, props) {
var cssString = '';
for (var p in props) {
cssString += p + ':' + props[p] + ';';
}
el.style.cssText += ';' + cssString;
}
function findPoster(playlist) {
var poster,
item;
for (var i in playlist) {
item = playlist[i];
if (item.constructor === Array) {
poster = findPoster(item);
} else {
if (item.type.search(/^image/) > -1) {
return item;
}
}
if (poster) {
return poster;
}
}
}
function createEl(name, props) {
var el = document.createElement(name);
for (var prop in props) {
el[prop] = props[prop];
}
return el;
}
function DriveIn() {

@@ -83,2 +25,3 @@ this._listeners = [];

this.loop = true;
this.loopPlaylistItems = false;
this.slideshow = false;

@@ -90,2 +33,3 @@

this._slideshowTimer = null;
this._seeking = false;

@@ -101,5 +45,3 @@ this.poster = null;

var pad = 1,
container = document.body,
parentEl = this.parentEl;
var pad = 1;

@@ -114,3 +56,3 @@ var containerW = getWidth(),

setStyles(parentEl, {
setStyles(this.parentEl, {
width: Math.ceil(containerH * mediaAspect) + 'px',

@@ -140,3 +82,3 @@ height: containerH + pad + 'px'

setStyles(parentEl, {
setStyles(this.parentEl, {
width: containerW + 'px',

@@ -149,3 +91,3 @@ height: Math.ceil(containerW / mediaAspect) + 1 + 'px'

setStyles(mediaEl, {
width: parentEl.offsetWidth + 'px',
width: this.parentEl.offsetWidth + 'px',
height: 'auto'

@@ -211,7 +153,5 @@ });

mediaEl.preload = 'auto';
if (this.playlistLength < 2 || this.loopPlaylistItems) mediaEl.loop = true;
if (this.mute) this.setVolume(0);
for (var j = sourceEls.length - 1; j >= 0; j--) {
mediaEl.appendChild(sourceEls[j]);
}
if (posterSrc) {

@@ -221,5 +161,3 @@ mediaEl.poster = posterSrc;

if (this.playlistLength < 2) mediaEl.loop = true;
if (this.mute) this.setVolume(0);
replaceChildren(mediaEl, sourceEls);
this.currentItem = itemNum;

@@ -293,2 +231,4 @@

}
this._seeking = false;
};

@@ -454,5 +394,16 @@

this.on('media.ended', function () {
function onMediaEnded() {
if (this._seeking) return;
var itemNum = 0;
if (self.playlistLength > 1 && self.loopPlaylistItems) {
if( self.currMediaType === 'image') {
// Images need a reboot, video is handled via `loop`
self.play(self.currentItem);
}
return;
}
if (self.playlistLength > 1 && self.loop) {
var itemNum = 0;
if (self.currentItem + 1 < self.playlistLength) {

@@ -463,17 +414,22 @@ itemNum = self.currentItem + 1;

}
});
}
this.on('media.canplay', function () {
function onMediaCanplay() {
mediaEl.style.opacity = 1;
self.canplay = true;
});
}
this.on('media.metadata', function () {
function onMediaMetadata() {
self.metadataLoaded = true;
});
}
this.on('media.loading', function () {
function onMediaLoading() {
self.canplay = false;
self.metadataLoaded = false;
});
}
this.on('media.ended', onMediaEnded);
this.on('media.canplay', onMediaCanplay);
this.on('media.metadata', onMediaMetadata);
this.on('media.loading', onMediaLoading);
};

@@ -613,5 +569,14 @@

}
if (options.hasOwnProperty('loop')) {
this.loop = options.loop;
}
if (options.hasOwnProperty('loopPlaylistItems')) {
this.loopPlaylistItems = options.loopPlaylistItems;
if (this.loopPlaylistItems) {
this.loop = false;
}
}
var playlist = Playlist.makePlaylist(rawPlaylist);

@@ -665,2 +630,4 @@

DriveIn.prototype.play = function(itemNum) {
this._seeking = true;
if (typeof itemNum === 'number') {

@@ -667,0 +634,0 @@ this._playItem(this.playlist[itemNum], itemNum);

{
"name": "drive-in",
"version": "1.2.0",
"version": "1.3.0",
"description": "Core library for React Drive-In",

@@ -5,0 +5,0 @@ "main": "index.js",

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