Last active
August 3, 2018 13:26
-
-
Save hakilebara/513b3af69dde8489e56916d0017499fd to your computer and use it in GitHub Desktop.
image slider
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
import Component from '@ember/component'; | |
import { computed } from '@ember/object'; | |
export default Component.extend({ | |
index: 0, | |
selectedAttachment: computed('attachments.[]', 'index', function() { | |
return this.attachments[Number(this.index)]; | |
}), | |
isFirstAttachment: computed('attachments.[]', 'index', function() { | |
return this.index === 0; | |
}), | |
isLastAttachment: computed('attachments.[]', 'index', function() { | |
return this.index === this.attachments.get('length') - 1; | |
}), | |
actions: { | |
prev() { | |
if (this.isFirstAttachment) return; | |
this.decrementProperty('index') | |
}, | |
next() { | |
if (this.isLastAttachment) return; | |
this.incrementProperty('index'); | |
} | |
} | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
tagName: '' | |
}); |
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
import Ember from 'ember'; | |
const images = [ | |
{url: "https://i.imgur.com/wgsdhsw.png"}, | |
{url: "https://i.imgur.com/8Uxcct4.png"}, | |
{url: "https://i.imgur.com/IcNcoMr.png"} | |
]; | |
export default Ember.Controller.extend({ | |
init() { | |
this._super(...arguments); | |
this.set('attachments', images); | |
} | |
}); |
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
body { | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.attachment-preview { | |
align-items: center; | |
display: flex; | |
justify-content: space-around; | |
height: 100vh; | |
width: 100vw; | |
} | |
.prev, .next { | |
align-items: center; | |
background-color: #FFF; | |
border: solid 1px black; | |
border-radius: 50%; | |
display: flex; | |
height: 40px; | |
justify-content: center; | |
max-width: 40px; | |
opacity: 1; | |
transition: opacity .4s; | |
width: 100%; | |
} | |
.prev.disabled, .next.disabled { | |
opacity: 0; | |
} | |
.prev { | |
transform: rotate(180deg); | |
} | |
svg { | |
width: 16px; | |
} | |
img { | |
max-width: 300px; | |
} |
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
{ | |
"version": "0.15.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.2.2", | |
"ember-template-compiler": "3.2.2", | |
"ember-testing": "3.2.2" | |
}, | |
"addons": { | |
"ember-data": "3.2.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment