-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
64 lines (58 loc) · 1.86 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
Vue.use('TextareaAutosize');
Vue.filter('username', value => {
return value.toLowerCase().replace(/\s/g, '');
})
var app = new Vue({
el: '#app',
data: {
article: {
headline: 'As California Struggles to Manage Wildfires, Health Problems Ensue',
image: 'images/sample.jpg',
position: 'bottom',
invert: true,
zoom: '100',
},
post: {
liked: false,
comments: 3,
username: 'bhsjacket',
verified: true,
avatar: 'images/avatar.jpg'
},
status: 'Download'
},
methods: {
setArticleImage: function(event) {
let image = event.target.files[0];
this.article.image = URL.createObjectURL(image);
},
downloadImage: function(event) {
this.status = 'Loading...';
let element = document.querySelector('.instagram-post .post-content');
let distance = element.clientHeight;
let scale = 3;
let options = {
height: distance * scale,
width: distance * scale,
style: {
'transform': 'scale(' + 3 + ')',
'transform-origin': 'top left'
}
}
domtoimage.toJpeg(element, options)
.then(result => {
let link = document.createElement('a');
link.style.display = 'none';
link.href = result;
link.download = 'post.jpeg',
document.body.appendChild(link);
link.click();
link.remove();
this.status = 'Download';
element.removeAttribute('style');
})
}
}
})
// Randomize comment count
app.post.comments = Math.round( Math.random() * 10 ) + 1;