-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added code sandbox link for examples - Fixed #46
- Loading branch information
Showing
12 changed files
with
93 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,47 @@ | ||
import ImageViewer from '../../src/ImageViewer'; | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
const images = [{ | ||
small: '../images/1.jpg', | ||
big: '../images/1_big.jpg', | ||
}, { | ||
small: '../images/2.jpg', | ||
big: '../images/2_big.jpg', | ||
}, { | ||
small: '../images/3.jpg', | ||
big: '../images/3_big.jpg', | ||
}, { | ||
small: '../images/4.jpg', | ||
big: '../images/4_big.jpg', | ||
}]; | ||
|
||
let curImageIdx = 1; | ||
|
||
const total = images.length; | ||
const wrapper = document.getElementById('image-gallery'); | ||
|
||
const curSpan = wrapper.querySelector('.current'); | ||
const viewer = new ImageViewer(wrapper.querySelector('.image-container')); | ||
window.viewer = viewer; | ||
// display total count | ||
wrapper.querySelector('.total').innerHTML = total; | ||
|
||
function showImage () { | ||
const imgObj = images[curImageIdx - 1]; | ||
viewer.load(imgObj.small, imgObj.big); | ||
curSpan.innerHTML = curImageIdx; | ||
} | ||
|
||
wrapper.querySelector('.next').addEventListener('click', function (evt) { | ||
curImageIdx++; | ||
if (curImageIdx > total) curImageIdx = 1; | ||
showImage(); | ||
}); | ||
|
||
wrapper.querySelector('.prev').addEventListener('click', function (evt) { | ||
curImageIdx--; | ||
if (curImageIdx < 0) curImageIdx = total; | ||
showImage(); | ||
}); | ||
|
||
// initially show image | ||
const images = [{ | ||
small: '../images/1.jpg', | ||
big: '../images/1_big.jpg', | ||
}, { | ||
small: '../images/2.jpg', | ||
big: '../images/2_big.jpg', | ||
}, { | ||
small: '../images/3.jpg', | ||
big: '../images/3_big.jpg', | ||
}, { | ||
small: '../images/4.jpg', | ||
big: '../images/4_big.jpg', | ||
}]; | ||
|
||
let curImageIdx = 1; | ||
|
||
const total = images.length; | ||
const wrapper = document.getElementById('image-gallery'); | ||
|
||
const curSpan = wrapper.querySelector('.current'); | ||
const viewer = new ImageViewer(wrapper.querySelector('.image-container')); | ||
window.viewer = viewer; | ||
// display total count | ||
wrapper.querySelector('.total').innerHTML = total; | ||
|
||
function showImage () { | ||
const imgObj = images[curImageIdx - 1]; | ||
viewer.load(imgObj.small, imgObj.big); | ||
curSpan.innerHTML = curImageIdx; | ||
} | ||
|
||
wrapper.querySelector('.next').addEventListener('click', function (evt) { | ||
curImageIdx++; | ||
if (curImageIdx > total) curImageIdx = 1; | ||
showImage(); | ||
}); | ||
|
||
wrapper.querySelector('.prev').addEventListener('click', function (evt) { | ||
curImageIdx--; | ||
if (curImageIdx < 0) curImageIdx = total; | ||
showImage(); | ||
}); | ||
|
||
// initially show image | ||
showImage(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import ImageViewer from '../../src/ImageViewer'; | ||
|
||
document.addEventListener('DOMContentLoaded', function () { | ||
Array.from(document.querySelectorAll('.pannable-image')).forEach((elem) => { | ||
new ImageViewer(elem); | ||
}); | ||
Array.from(document.querySelectorAll('.pannable-image')).forEach((elem) => { | ||
new ImageViewer(elem); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
body, | ||
html { | ||
margin: 0; | ||
} | ||
|
||
.header { | ||
border-bottom: 1px solid #ccc; | ||
text-align: center; | ||
padding: 10px; | ||
} | ||
|
||
.nav-link { | ||
text-decoration: none; | ||
padding: 10px; | ||
} | ||
|
||
nav { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
<html> | ||
<head> | ||
<title>Image Viewer Example</title> | ||
<meta charset="UTF-8" /> | ||
<link rel="stylesheet" href="index.css" /> | ||
</head> | ||
<body> | ||
<h1 class="header">ImageViewer examples</h1> | ||
<nav> | ||
<a href="./container-mode/example.html" >Container Mode</a> | ||
<a href="./fullscreen-mode/example.html" >Full Screen Mode</a> | ||
<a href="./image-mode/example.html" >Image Mode</a> | ||
<a class="nav-link" href="/container-mode/example.html">Container Mode</a> | ||
<a class="nav-link" href="/fullscreen-mode/example.html"> | ||
Full Screen Mode | ||
</a> | ||
<a class="nav-link" href="/image-mode/example.html">Image Mode</a> | ||
</nav> | ||
<script src="../src/ImageViewer.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters