Skip to content
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
118 changes: 65 additions & 53 deletions gallery-via-json-noprocess.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,73 @@
AFRAME.registerComponent('gallery-via-json', {
schema: {
thumbWidth: {type: 'number', default: 100},
thumbHeight: {type: 'number', default: 80},
borderColor: {type: 'string', default: '#fff'},
activeColor: {type: 'string', default: '#fff'},
backgroundColor: {type: 'string', default: 'transparent'},
},
init: function () {
// Create our stylesheet
// Create our stylesheet
var style = document.createElement('style');
style.innerHTML =
'.gallery {' +
'background: transparent;' +
'margin: auto;' +
'text-align: center;' +
'position: absolute;' +
'bottom: 0px;' +
'width: 100%;' +
'padding: 5px 0;' +
'}' +
'.scrolling { ' +
'overflow-x: scroll;' +
'overflow-y: hidden;' +
'height: 112px;' +
'white-space:nowrap' +
'} ' +
'.scrolling .thumb img { ' +
'height: 100%; ' +
'min-width: 100%; ' +
'top: 50%; ' +
'left: 50%; ' +
'position: absolute; ' +
'transform: translate(-50%,-50%); ' +
'} ' +
'.scrolling .thumb { ' +
'width: 100px; ' +
'height: 80px; ' +
'overflow: hidden; ' +
'position: relative; ' +
'margin: 5px; ' +
'width: 100px; ' +
'border: 1px solid #fff;' +
'box-shadow: 1px 1px 5px rgba(0,0,0,0.5); ' +
'opacity: 0.7;' +
'max-height: 80px;' +
'cursor: pointer;' +
'display:inline-block;' +
'*display:inline;' +
'*zoom:1;' +
'vertical-align:top;' +
'}' +
'.scrolling .thumb:hover, .scrolling .thumb.active {' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'}';

// Get the first script tag
var ref = document.querySelector('script');
var data = this.data;
// Create our stylesheet
var style = document.createElement('style');
style.innerHTML =
'.gallery {' +
'background: ' + data.backgroundColor + ';' +
'margin: auto;' +
'text-align: center;' +
'position: absolute;' +
'bottom: 0px;' +
'width: 100%;' +
'padding: 5px 0;' +
'}' +
'.scrolling { ' +
'overflow-x: scroll;' +
'overflow-y: hidden;' +
'height: ' + (data.thumbHeight+12) + 'px;' +
'white-space:nowrap' +
'} ' +
'.scrolling .thumb img { ' +
'height: 100%; ' +
'min-width: 100%; ' +
'top: 50%; ' +
'left: 50%; ' +
'position: absolute; ' +
'transform: translate(-50%,-50%); ' +
'} ' +
'.scrolling .thumb { ' +
'width: ' + data.thumbWidth + 'px; ' +
'height: ' + data.thumbHeight + 'px; ' +
'overflow: hidden; ' +
'position: relative; ' +
'margin: 5px; ' +
'border: 1px solid ' + data.borderColor + ';' +
'box-shadow: 1px 1px 5px rgba(0,0,0,0.5); ' +
'opacity: 0.7;' +
'max-height: ' + data.thumbHeight + 'px; ' +
'cursor: pointer;' +
'display:inline-block;' +
'*display:inline;' +
'*zoom:1;' +
'vertical-align:top;' +
'}' +
'.scrolling .thumb:hover {' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'}' +
'.scrolling .thumb.active {' +
'border: 1px solid ' + data.activeColor + ';' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'}';

// Insert our new styles before the first script tag
ref.parentNode.insertBefore(style, ref);
// Get the first script tag
var ref = document.querySelector('script');

// Insert our new styles before the first script tag
ref.parentNode.insertBefore(style, ref);

var i = 0;
if(window.location.hash) {
Expand Down
62 changes: 43 additions & 19 deletions gallery-via-json.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,64 @@
AFRAME.registerComponent('gallery-via-json', {
schema: {
thumbWidth: {type: 'number', default: 100},
thumbHeight: {type: 'number', default: 80},
borderColor: {type: 'string', default: '#fff'},
activeColor: {type: 'string', default: '#fff'},
backgroundColor: {type: 'string', default: 'transparent'},
},
init: function () {
// Create our stylesheet
var style = document.createElement('style');
style.innerHTML =
'.gallery {' +
'background: transparent;' +
'margin: auto;' +
'text-align: center;' +
'position: absolute;' +
'bottom: 0px;' +
'width: 100%;' +
'padding: 5px 0;' +
'background: ' + data.backgroundColor + ';' +
'margin: auto;' +
'text-align: center;' +
'position: absolute;' +
'bottom: 0px;' +
'width: 100%;' +
'padding: 5px 0;' +
'}' +
'.scrolling { ' +
'overflow-x: scroll;' +
'overflow-y: hidden;' +
'height: 112px;' +
'white-space:nowrap' +
'overflow-x: scroll;' +
'overflow-y: hidden;' +
'height: ' + (data.thumbHeight+12) + 'px;' +
'white-space:nowrap' +
'} ' +
'.scrolling img { ' +
'.scrolling .thumb img { ' +
'height: 100%; ' +
'min-width: 100%; ' +
'top: 50%; ' +
'left: 50%; ' +
'position: absolute; ' +
'transform: translate(-50%,-50%); ' +
'} ' +
'.scrolling .thumb { ' +
'width: ' + data.thumbWidth + 'px; ' +
'height: ' + data.thumbHeight + 'px; ' +
'overflow: hidden; ' +
'position: relative; ' +
'margin: 5px; ' +
'width: 100px; ' +
'border: 1px solid #fff;' +
'border: 1px solid ' + data.borderColor + ';' +
'box-shadow: 1px 1px 5px rgba(0,0,0,0.5); ' +
'opacity: 0.7;' +
'max-height: 80px;' +
'max-height: ' + data.thumbHeight + 'px; ' +
'cursor: pointer;' +
'display:inline-block;' +
'*display:inline;' +
'*zoom:1;' +
'vertical-align:top;' +
'}' +
'.scrolling img:hover, .scrolling img.active {' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'.scrolling .thumb:hover {' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'}' +
'.scrolling .thumb.active {' +
'border: 1px solid ' + data.activeColor + ';' +
'box-shadow: 1px 1px 10px rgba(0,0,0,0.25);' +
'opacity: 1;' +
'transform: scale(1.1);' +
'}';

// Get the first script tag
Expand Down
19 changes: 19 additions & 0 deletions gallery_params.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<html>
<head>
<script src="https://aframe.io/aframe/dist/aframe-master.min.js"></script>
<script src="gallery-via-json.js"></script>
</head>
<body>
<a-scene>
<a-sky
gallery-via-json="
thumbWidth:60;
thumbHeight:40;
borderColor:blue;
activeColor:red;
backgroundColor:yellow;
">
</a-sky>
</a-scene>
</body>
</html>