Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better zoom & some gestures #93

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules/
log/
tmp/
2 changes: 1 addition & 1 deletion dist/css/spotlight.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/img/info.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 24 additions & 20 deletions dist/js/spotlight.min.js

Large diffs are not rendered by default.

46 changes: 25 additions & 21 deletions dist/spotlight.bundle.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
/* custom animation "visible state" (css context by custom classname "only-this-gallery" to apply these animation just on a specific gallery) */
.only-this-gallery.show .spl-pane > *{
clip-path: circle(100% at center);
}
.only-this-gallery.show .spl-pane, .only-this-gallery.show .spl-pane > *{
/* setting custom transition duration might mess up zoom animations */
/* one should set an identical transition duration for ".spl-pane" and ".spl-pane > *" */
transition: transform 0.35s ease,
opacity 0.65s ease,
clip-path 0.8s ease;
Expand Down Expand Up @@ -104,6 +108,7 @@ <h1>
<img src="demo/gallery/montana-1829251-thumb.jpg">
</a>
<div class="spotlight" data-src="demo/gallery/brooklyn-bridge-1791001.jpg"></div>
<div class="spotlight" data-media="node" data-src="#long"></div>
</div>
<!-- Hidden Backstore -->
<div style="display: none">
Expand All @@ -113,6 +118,10 @@ <h1>
<img class="image" src="demo/gallery/california-1751455-thumb.jpg" width="500" height="333">
<img class="image" src="demo/gallery/montana-1829251-thumb.jpg" width="500" height="331">
</div>
<div id="long" style="width: 5em; height: 5em; overflow: scroll; background-color: pink; color: black">
L<br>O<br>N<br>G<br><br>C<br>O<br>N<br>T<br>E<br>N<br>T<br>
<pre style="word-wrap: no-wrap">-----W-----I-----D-----E-----</div>
</div>
</div>
<br>
<hr>
Expand Down Expand Up @@ -320,4 +329,4 @@ <h1>

</script>
</body>
</html>
</html>
69 changes: 50 additions & 19 deletions src/js/helper.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,65 @@
/**
* @param node
* @param class_name
* @param {HTMLElement} node
* @param {string} class_name
*/

export function addClass(node, class_name){

toggleClass(node, class_name, true);
node.classList.add(class_name);
}

/**
* @param node
* @param class_name
* @param {HTMLElement} node
* @param {string} class_name
*/

export function removeClass(node, class_name){

toggleClass(node, class_name);
node.classList.remove(class_name);
}

/**
* @param node
* @param class_name
* @param {?=} state
* @param {HTMLElement} node
* @param {string} class_name
* @param state
*/

export function toggleClass(node, class_name, state){

node.classList[state ? "add" : "remove"](class_name);
if(state){

addClass(node, class_name);
}
else{

removeClass(node, class_name);
}
}

/**
* @param node
* @param class_name
* @param {HTMLElement} node
* @param {string} class_name
*/

export function hasClass(node, class_name){

return node.classList.contains(class_name);
}

/**
* @param {HTMLElement} node
*/

export function restoreStyle(node){
for(var key in node){

if(key.startsWith("_s_")){

node.style.setProperty(key.substring(3), node[key]);
}
}
}

/**
* @param {HTMLElement} node
* @param {string} style
Expand All @@ -59,7 +80,7 @@ export function setStyle(node, style, value){
let tmp = 0;

/**
* @param node
* @param {HTMLElement} node
* @param {Function=} fn
*/

Expand All @@ -77,6 +98,11 @@ export function prepareStyle(node, fn){
fn && setStyle(node, "transition", "");
}

/**
* @param {HTMLElement} node
* @param {string} text
*/

export function setText(node, text){

node.firstChild.nodeValue = text;
Expand Down Expand Up @@ -142,7 +168,7 @@ export function toggleListener(state, node, event, fn, mode){
}

/**
* @param event
* @param {Event} event
* @param {boolean=} prevent
*/

Expand All @@ -153,6 +179,11 @@ export function cancelEvent(event, prevent){
prevent && event.preventDefault();
}

/**
* @param {HTMLBodyElement} body
* @param {HTMLElement} image
*/

export function downloadImage(body, image){

const link = /** @type {HTMLAnchorElement} */ (createElement("a"));
Expand All @@ -166,16 +197,16 @@ export function downloadImage(body, image){

/**
* @param {!string} element
* @return {Element}
* @return {HTMLElement}
*/

export function createElement(element){

return document.createElement(element);
return /** @type {HTMLElement} */ (document.createElement(element));
}

/**
* @param node
* @param {HTMLElement} node
* @param {boolean=} state
*/

Expand All @@ -185,7 +216,7 @@ export function toggleDisplay(node, state){
}

/**
* @param node
* @param {HTMLElement} node
* @param {boolean=} state
*/

Expand All @@ -195,7 +226,7 @@ export function toggleVisibility(node, state){
}

/**
* @param node
* @param {HTMLElement} node
* @param {boolean=} state
*/

Expand Down
9 changes: 9 additions & 0 deletions src/js/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import { createElement } from "./helper.js";
const video_support = {};
const tpl_video = /** @type {HTMLVideoElement} */ (createElement("video"));

/**
*
* @param {HTMLAnchorElement} anchor
* @param {number} size
* @param options
* @param {string} media
* @returns {string}
*/

export default function(anchor, size, options, media){

let src, diff;
Expand Down
Loading