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

smartphoto

Package Overview
Dependencies
Maintainers
1
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

smartphoto - npm Package Compare versions

Comparing version 0.2.14 to 0.3.0

js/jquery-smartphoto.min.js

68

lib/core/index.js

@@ -9,4 +9,2 @@ 'use strict';

var _zeptoBrowserify = require('zepto-browserify');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -99,4 +97,4 @@

_this.data.isSmartPhone = _this._isSmartPhone();
(0, _zeptoBrowserify.$)('body').append('<div data-id=\'' + _this.id + '\'></div>');
var body = document.querySelector('body');
util.append(body, '<div data-id=\'' + _this.id + '\'></div>');
[].forEach.call(_this.elements, function (element, index) {

@@ -122,3 +120,3 @@ _this.addNewItem(element);

if (!_this.data.isSmartPhone) {
(0, _zeptoBrowserify.$)(window).resize(function () {
window.addEventListener("resize", function (e) {
_this._resetTranslate();

@@ -131,3 +129,3 @@ _this._setPosByCurrentIndex();

(0, _zeptoBrowserify.$)(window).on("orientationchange", function (e) {
window.addEventListener("orientationchange", function (e) {
_this._resetTranslate();

@@ -144,3 +142,3 @@ _this._setPosByCurrentIndex();

(0, _zeptoBrowserify.$)(window).on("deviceorientation", function (e) {
window.addEventListener("deviceorientation", function (e) {
var originalEvent = e.originalEvent || e;

@@ -389,5 +387,2 @@ var orientation = window.orientation;

}, {
key: 'addLeaveEffect',
value: function addLeaveEffect() {}
}, {
key: 'hidePhoto',

@@ -400,7 +395,8 @@ value: function hidePhoto() {

this.data.appearEffect = null;
var scrollLocation = (0, _zeptoBrowserify.$)(window).scrollTop();
var scrollX = window.scrollX;
var scrollY = window.scrollY;
if (location.hash) {
location.hash = "";
}
(0, _zeptoBrowserify.$)(window).scrollTop(scrollLocation);
window.scroll(scrollX, scrollY);
this._doHideEffect().then(function () {

@@ -482,3 +478,4 @@ _this6.update();

value: function _setHashByCurrentIndex() {
var scrollLocation = (0, _zeptoBrowserify.$)(window).scrollTop();
var scrollX = window.scrollX;
var scrollY = window.scrollY;
var items = this.groupItems();

@@ -489,3 +486,3 @@ var id = items[this.data.currentIndex].id;

location.hash = hash;
(0, _zeptoBrowserify.$)(window).scrollTop(scrollLocation);
window.scroll(scrollX, scrollY);
}

@@ -992,4 +989,6 @@ }, {

var classNames = this.data.classNames;
var $current = (0, _zeptoBrowserify.$)('.current', '[data-id="' + this.id + '"]');
var $this = (0, _zeptoBrowserify.$)('.' + classNames.smartPhotoImg, $current);
var current = this._getElementByQuery('.current');
var img = current.querySelector('.' + classNames.smartPhotoImg);
var nav = this._getElementByQuery('.' + classNames.smartPhotoNav);
var arrows = this._getElementByQuery('.' + classNames.smartPhotoArrows);
var photoPosX = this.virtualPos(this.data.photoPosX);

@@ -999,28 +998,27 @@ var photoPosY = this.virtualPos(this.data.photoPosY);

var transform = 'translate(' + photoPosX + 'px,' + photoPosY + 'px) scale(' + scaleSize + ')';
var $nav = (0, _zeptoBrowserify.$)('.' + classNames.smartPhotoNav, '[data-id="' + this.id + '"]');
var $arrows = (0, _zeptoBrowserify.$)('.' + classNames.smartPhotoArrows, '[data-id="' + this.id + '"]');
$this.css('transform', transform);
img.style.transform = transform;
if (this.data.scale) {
$this.addClass(classNames.smartPhotoImgOnMove);
util.addClass(img, classNames.smartPhotoImgOnMove);
} else {
$this.removeClass(classNames.smartPhotoImgOnMove);
util.removeClass(img, classNames.smartPhotoImgOnMove);
}
if (this.data.elastic) {
$this.addClass(classNames.smartPhotoImgElasticMove);
util.addClass(img, classNames.smartPhotoImgElasticMove);
} else {
$this.removeClass(classNames.smartPhotoImgElasticMove);
util.removeClass(img, classNames.smartPhotoImgElasticMove);
}
if (this.data.hideUi) {
$nav.addClass('hide');
$arrows.addClass('hide');
util.addClass(nav, 'hide');
util.addClass(arrows, 'hide');
setTimeout(function () {
$nav.addClass('none');
$arrows.addClass('none');
util.addClass(nav, 'none');
util.addClass(arrows, 'none');
}, 100);
} else {
$nav.removeClass('none');
$arrows.removeClass('none');
util.removeClass(nav, 'none');
util.removeClass(arrows, 'none');
setTimeout(function () {
$nav.removeClass('hide');
$arrows.removeClass('hide');
util.removeClass(nav, 'hide');
util.removeClass(arrows, 'hide');
}, 10);

@@ -1033,10 +1031,10 @@ }

var classNames = this.data.classNames;
var $list = (0, _zeptoBrowserify.$)('.' + classNames.smartPhotoList, '[data-id="' + this.id + '"]');
var list = this._getElementByQuery('.' + classNames.smartPhotoList);
var transform = 'translate(' + this.data.translateX + 'px,' + this.data.translateY + 'px)';
$list.css('transform', transform);
list.style.transform = transform;
// $list
if (this.data.onMoveClass) {
$list.addClass(classNames.smartPhotoListOnMove);
util.addClass(list, classNames.smartPhotoListOnMove);
} else {
$list.removeClass(classNames.smartPhotoListOnMove);
util.removeClass(list, classNames.smartPhotoListOnMove);
}

@@ -1043,0 +1041,0 @@ }

@@ -76,2 +76,24 @@ 'use strict';

}
};
module.exports.append = function (element, string) {
var parser = new DOMParser();
var doc = parser.parseFromString(string, 'text/html');
element.appendChild(doc.querySelector('body').childNodes[0]);
};
module.exports.addClass = function (element, className) {
if (element.classList) {
element.classList.add(className);
} else {
element.className += ' ' + className;
}
};
module.exports.removeClass = function (element, className) {
if (element.classList) {
element.classList.remove(className);
} else {
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
};
{
"name": "smartphoto",
"version": "0.2.14",
"version": "0.3.0",
"description": "smartphoto",

@@ -47,6 +47,5 @@ "homepage": "http://developer.a-blogcms.jp",

"dependencies": {
"a-template": "0.1.4",
"keyboard-js": "^1.1.4",
"zepto-browserify": "^1.1.6-1"
"a-template": "0.2.0",
"keyboard-js": "^1.1.4"
}
}
import aTemplate from 'a-template';
import { $ } from 'zepto-browserify';
import template from './viwer.html';

@@ -78,4 +77,4 @@

this.data.isSmartPhone = this._isSmartPhone();
$('body').append(`<div data-id='${this.id}'></div>`);
const body = document.querySelector('body');
util.append(body,`<div data-id='${this.id}'></div>`);
[].forEach.call(this.elements, (element,index) => {

@@ -101,3 +100,3 @@ this.addNewItem(element);

if(!this.data.isSmartPhone){
$(window).resize(() => {
window.addEventListener("resize", (e) => {
this._resetTranslate();

@@ -110,3 +109,3 @@ this._setPosByCurrentIndex();

$(window).on("orientationchange", (e) => {
window.addEventListener("orientationchange", (e) => {
this._resetTranslate();

@@ -123,3 +122,3 @@ this._setPosByCurrentIndex();

$(window).on("deviceorientation", (e) => {
window.addEventListener("deviceorientation", (e) => {
let originalEvent = e.originalEvent || e;

@@ -346,6 +345,2 @@ const orientation = window.orientation;

addLeaveEffect () {
}
hidePhoto () {

@@ -355,7 +350,8 @@ this.data.hide = true;

this.data.appearEffect = null;
const scrollLocation = $(window).scrollTop();
const scrollX = window.scrollX;
const scrollY = window.scrollY;
if (location.hash) {
location.hash = "";
}
$(window).scrollTop( scrollLocation );
window.scroll(scrollX,scrollY);
this._doHideEffect().then(() => {

@@ -429,3 +425,4 @@ this.update();

_setHashByCurrentIndex () {
const scrollLocation = $(window).scrollTop();
const scrollX = window.scrollX;
const scrollY = window.scrollY;
const items = this.groupItems();

@@ -436,3 +433,3 @@ const id = items[this.data.currentIndex].id;

location.hash = hash;
$(window).scrollTop( scrollLocation );
window.scroll(scrollX,scrollY);
}

@@ -901,4 +898,6 @@

const classNames = this.data.classNames;
const $current = $('.current',`[data-id="${this.id}"]`);
const $this = $(`.${classNames.smartPhotoImg}`,$current);
const current = this._getElementByQuery('.current');
const img = current.querySelector(`.${classNames.smartPhotoImg}`);
const nav = this._getElementByQuery(`.${classNames.smartPhotoNav}`);
const arrows = this._getElementByQuery(`.${classNames.smartPhotoArrows}`);
const photoPosX = this.virtualPos(this.data.photoPosX);

@@ -908,28 +907,27 @@ const photoPosY = this.virtualPos(this.data.photoPosY);

const transform = `translate(${photoPosX}px,${photoPosY}px) scale(${scaleSize})`;
const $nav = $(`.${classNames.smartPhotoNav}`,`[data-id="${this.id}"]`);
const $arrows = $(`.${classNames.smartPhotoArrows}`,`[data-id="${this.id}"]`);
$this.css('transform',transform);
img.style.transform = transform;
if (this.data.scale) {
$this.addClass(classNames.smartPhotoImgOnMove);
util.addClass(img,classNames.smartPhotoImgOnMove);
} else {
$this.removeClass(classNames.smartPhotoImgOnMove);
util.removeClass(img,classNames.smartPhotoImgOnMove);
}
if (this.data.elastic) {
$this.addClass(classNames.smartPhotoImgElasticMove);
util.addClass(img,classNames.smartPhotoImgElasticMove);
} else {
$this.removeClass(classNames.smartPhotoImgElasticMove);
util.removeClass(img,classNames.smartPhotoImgElasticMove);
}
if (this.data.hideUi) {
$nav.addClass('hide');
$arrows.addClass('hide');
setTimeout(() =>{
$nav.addClass('none');
$arrows.addClass('none');
util.addClass(nav,'hide');
util.addClass(arrows,'hide');
setTimeout(() => {
util.addClass(nav,'none');
util.addClass(arrows,'none');
},100)
} else {
$nav.removeClass('none');
$arrows.removeClass('none');
setTimeout(() =>{
$nav.removeClass('hide');
$arrows.removeClass('hide');
util.removeClass(nav,'none');
util.removeClass(arrows,'none');
setTimeout(() => {
util.removeClass(nav,'hide');
util.removeClass(arrows,'hide');
},10)

@@ -941,10 +939,10 @@ }

const classNames = this.data.classNames;
const $list = $(`.${classNames.smartPhotoList}`,`[data-id="${this.id}"]`);
const list = this._getElementByQuery(`.${classNames.smartPhotoList}`);
const transform = `translate(${this.data.translateX}px,${this.data.translateY}px)`;
$list.css('transform',transform);
list.style.transform = transform;
// $list
if(this.data.onMoveClass) {
$list.addClass(classNames.smartPhotoListOnMove);
util.addClass(list,classNames.smartPhotoListOnMove);
}else{
$list.removeClass(classNames.smartPhotoListOnMove);
util.removeClass(list,classNames.smartPhotoListOnMove);
}

@@ -951,0 +949,0 @@ }

@@ -74,2 +74,24 @@ module.exports.isSmartPhone = () => {

}
}
}
module.exports.append = (element,string) => {
const parser = new DOMParser();
const doc = parser.parseFromString(string, 'text/html');
element.appendChild(doc.querySelector('body').childNodes[0]);
}
module.exports.addClass = (element,className) => {
if (element.classList) {
element.classList.add(className);
} else {
element.className += ` ${className}`;
}
}
module.exports.removeClass = (element,className) => {
if (element.classList) {
element.classList.remove(className);
} else {
element.className = element.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' ');
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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