How to update iframe in vue.js - vue.js

I have an Iframe
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d" :src="this.$store.getters['rackStore/getIframe'].ref" id="iframe_3d" allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; "></iframe>
And it displays the data perfectly.
Src I take from Vuex
Then I want to change the src value:
let iframe_param = this.$store.getters['rackStore/getIframe'];
this.$store.commit('rackStore/setIframe', { ...iframe_param, show: 'iframe', ref: model.ref } );
And I mean in the console that the src value of the iframe is changing!
But the iframe itself is not updated in the browser for some reason.
I tried to force update it: this.$ForceUpdate ();
This does not work.
I've tried changing the src in the usual way without Vue, this also doesn't work:
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d"
src="" id="iframe_3d"
allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; ">
</iframe>
var iframe = document.getElementById('iframe_3d');
iframe.src = model.ref;
src changes but no data refresh occurs, the previous site is still open in the iframe
What to do?
Thank you in advance!

Try update the element using key attribute:
<template>
<!-- ... -->
<iframe v-show="this.$store.getters['rackStore/getIframe'].show === 'iframe'" ref="iframe_3d" :src="this.$store.getters['rackStore/getIframe'].ref" id="iframe_3d" allowfullscreen="true" style="width: 100%; height: 100%; z-index: -1; position: fixed; top: 0px; left: 0px; border: 1px solid #00f; " :key="iframeUpdate"></iframe>
<!-- ... -->
</template>
<script>
export default {
// ...
data() {
return {
iframeUpdate: false
}
},
}
</script>
When your value in Vuex changes, simultaneously change iframeUpdate variable value like this:
this.iframeUpdate = !this.iframeUpdate;

Related

Animate width of div bound to data property in Vue

I have this progress bar div, whichs width is bound to the data property result and changes accordingly. At the moment it still jumps, but I want to animate it. I thought of tracking the old and the new Value and injecting it in the css with css variables or just using a setInterval method, but tracking the 2 values seems to get quite complicated and it seemed like a overkill for me. Does anyone have an easier idea?
<template>
<div class="progress">
<div class="progress-value" :style="{ 'width': result + '%' }">
<h2>{{ result }}%</h2>
</div>
</div>
</template>
<script>
export default {
props: ["result"],
};
</script>
<style scoped>
.progress {
background: #ccc;
border-radius: 100px;
position: relative;
padding: 5px 5px;
margin: 5px 5px;
height: 40px;
width: auto;
}
.progress-value {
animation: load 3s normal forwards;
border-radius: 100px;
background: #fff;
height: 30px;
text-align: center;
}
/* #keyframes load {
0% {
width:
}
100% {
width:
}
} */
</style>
Add css transition like this:
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 1s;
And fix the binding:
<div class="progress-value" :style="'width: ' + result + '%'">
See this example
<template>
<div class="progress">
<div class="progress-value" :style="'width: ' + result + '%'">
<h2>{{ result }}%</h2>
</div>
</div>
</template>
<script>
export default {
data () {
return {
result: 5
}
},
mounted() {
this.increment()
},
methods: {
increment() {
this.result += 10
if (this.result < 95) {
setTimeout(this.increment, 1000)
}
}
}
}
</script>
<style scoped>
.progress {
background: #ccc;
border-radius: 100px;
position: relative;
padding: 5px 5px;
margin: 5px 5px;
height: 40px;
width: auto;
}
.progress-value {
transition-property: all;
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
transition-duration: 1s;
background: #fff;
height: 30px;
text-align: center;
}
</style>

v-show or v-if div shifted the others div into the parent container

I would like to add dynamically image (check arrow) into a div which contains other div information (image + texte).
This adding means that users owned this "object" in the application. He can added or deselected this object on the fly.
The result of this action is appear or disappear arrow on the fly.
This process run perfectly in my vue.js component. But I can view appear an offset each time that arrow appears like this :
I try to use v-if or v-show vue.js directives but the result is the same.
I don't want to have a new offset appear when action to checked item is launch.
this is the HTML template :
<div id="container">
<div #click="checkedItem(key.id)" class="container-item" v-for="(key, value) in objects">
<div class="check" v-show="checked[key.id]">
<img height="35" width="35" src="../../../static/checked.png"></img>
</div>
<div class="image">
<img src="https://picsum.photos/75/75/?image=25" alt="logo"></img>
</div>
<div class="name">{{ key.name }}</div>
</div>
</div>
This is the CSS stylesheet component :
<style scoped>
#container
{
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.container-item
{
display: flex;
flex-direction: row;
margin: 30px 30px 30px 30px;
}
.container-item div.check
{
z-index: 3;
position: relative;
left: 20px;
bottom: 15px;
}
.container-item div.check > img
{
height: 35px;
width: 35px;
}
.container-item div.image
{
z-index: 2;
border: 1px solid blue;
}
.container-item div.name
{
z-index: 1;
position: relative;
top: 12px;
right: 10px;
text-align: center;
line-height: 45px;
width: 150px;
max-height: 50px;
border: 1px solid blue;
background-color: yellow;
}
</style>
And the checkedItem method component :
checkedItem: function (id)
{
let isChecked = this.checked[id] ? true : false
isChecked ? this.checked[id] = false : this.checked[id] = true
},
How can "add" DOM node HTML into HTML template component vue.js whitout create a new offset on the fly ?
As we have discussed in the comments, this is purely a CSS thing. What you want is to take div.check out from the layout flow, so that it does not influence the positioning of other elements. This can be done by adding position: absolute to its ruleset. For that to work, remember to add position: relative to its parent, too:
.container-item {
display: flex;
flex-direction: row;
margin: 30px 30px 30px 30px;
/* Allow div.check to be positioned relative to its parent */
position: relative;
}
.container-item div.check {
z-index: 3;
left: 20px;
bottom: 15px;
/* Take the check icon out of layout flow */
position: absolute;
}

Instagram feed access token in shopify

I am new to shopify and I wanted to add the Instagram feed on the website I'm working on. This website is using Retina theme and I think this is not an updated theme. I read some articles like here about missing instagram feed in shopify store homepage and they said I need to have an access token. Now that I have my access token, I don't know what to do with it. I mean, where can I insert this token? Any help would be much appreciated.
{{ 'instafeed.min.js' | asset_url | script_tag }}
{{ 'https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css' | stylesheet_tag }}
<h2 class="instagram_heading" style="text-align: center;"><span style="color: #000;">Store Name</span><span style="font-weight:normal;"> On Instagram </span><a target="_blank" href="https://www.instagram.com/shopgear101/"> UserName</a></h2>
<section class="twitter-feed footer-bottom-margin">
<div id="instafeed" class="photo_list list-inline">
</div>
<script type="text/javascript">
var userFeed = new Instafeed({
get: 'user',
userId: 'userid', //Put The user id here..
accessToken: 'accesstoken', //Put The access token here..
limit: '10',
template: '<div class="twitter_img" style="background-image: url\(\{\{image\}\}\)"><div class="inner_image text-center"></div><a target="_blank" href="\{\{link\}\}"><div class="inner_image"><span class="text_like"><i class="fa fa-heart" aria-hidden="true"></i> \{\{likes\}\}</span></div></a></div>'
});
userFeed.run();
</script>
<style>
.twitter_img{
float:left;
position: relative;
width: 20%;
padding-bottom : 20%; /* = width for a 1:1 aspect ratio */
background-position:center center;
background-repeat:no-repeat;
background-size:cover; /* you change this to "contain" if you don't want the images to be cropped */
}
.inner_image {
position: absolute;
left: 0;
top: 0;
overflow: hidden;
background: rgba(0, 0 , 0,.5);
color: #fff;
width: 100%;
height: 100%;
opacity: 0;
}
.twitter_img:hover .inner_image{
opacity: 1;
transition: 0.3s ease;
}
.text_like{
font-size: 22px;
position: relative;
top: 47%;
left: 45%;
-webkit-transform: translateY(-50%);
-ms-transform: translateY(-50%);
transform: translateY(-50%);
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
#media screen and (max-width: 420px){
.twitter_img{
width: 50%;
height: 190px !important;
}
}
</style>
</section>
Well, it requires some coding skills. Try to use free Instagram apps from Shopify Apps Marketplace. You won't need to do anything except copy & paste the embed code:
https://apps.shopify.com/instagram-feed
https://apps.shopify.com/instagram-photos

Slider doesn't autostart in Explorer 11

I have been unable to get this code to work on IE11 - it works fine on Chrome and Firefox, Android Chrome, Opera, just not IE. In IE11, I can actually see the images pile in on top of one another until it reaches the last image, then it just stops. The last image is distorted (as if $FillMode is set to 0). However, while clicking on the image makes no difference, dragging it even the slightest amount triggers it into operation. It's as if the auto-start is ignored, but once nudged, the function works. If I do nothing, it sits on the last image loaded indefinitely.
The head:
<script type="text/javascript" src="css/jssor.slider.js"></script>
<script async>
jQuery(document).ready(function ($) {
var _SlideshowTransitions = [{$Duration:700,$Opacity:2,$Brother:{$Duration:1000,$Opacity:2}} ];
var _CaptionTransitions = [];
var startImgNumber =Math.floor((Math.random()*16)+1);
var options = {
$CaptionSliderOptions: {
$Class: $JssorCaptionSlider$,
$CaptionTransitions: _CaptionTransitions,
$PlayInMode: 1,
$PlayOutMode: 3},
$AutoPlay: true,
$DragOrientation: 1,
$AutoPlayInterval: 5000, // ADJUST!!!!
$FillMode: 1,
$SlideHeight: 260,
//$PauseOnHover: 0,
$StartIndex: startImgNumber,
$SlideshowOptions: {
$Class: $JssorSlideshowRunner$,
$Transitions: _SlideshowTransitions,
$TransitionsOrder: 1,
$ShowLink: true
}
};
var jssor_slider1 = new $JssorSlider$("slider1_container", options);
function ScaleSlider() {
var parentWidth = $('#slider1_container').parent().width();
if (parentWidth) {
jssor_slider1.$ScaleWidth(parentWidth);
}
else
window.setTimeout(ScaleSlider, 30);
}
//Scale slider after document ready
ScaleSlider();
//Scale slider while window load/resize/orientationchange.
$(window).bind("load", ScaleSlider);
$(window).bind("resize", ScaleSlider);
$(window).bind("orientationchange", ScaleSlider);
//responsive code end
});
</script>
HTML code is:
<div id="PhotoShow" >
<div id="slider1_container" style="position: relative; top: 0px; left: 0px width: 332px; height: 260px; ">
<!-- Slides Container -->
<div u="slides" style="cursor: move; position: absolute; left: 0px; top: 0px; width: 330px; height: 260px; overflow: hidden;">
<div><img data-u="image" src="photos/pic1.jpg" title="Photo By me ©2015" alt=""/><div u="caption" t="transition_name1" style="position: absolute; top: 245px; left: 100px; width: 200px;height: 30px; color:#FFFBF0; font-size:x-small" >Courtesy of me © 2015</div></div>
<div><img data-u="image" src="photos/pic2.jpg" title="Photo By me ©2015"alt=""/><div u="caption" t="transition_name1" style="position: absolute; top: 245px; left: 125px; width: 200px;height: 30px; color:#ffffff; font-size:x-small" >me © 2015</div></div>
.
.
. 16 images total
</div>
</div>
</div>
(Possible I have extra /div tags - that is not the issue, just a typo), I am completely at a loss as to why this works on everything except IE11. It appears that the function simply does not execute. I've tried window.onload and a few other things - changes nothing.
Thanks for any clues or suggestions
A semicolon is missing in your html code.
Please replace
<div id="slider1_container" style="position: relative; top: 0px; left: 0px width: 332px; height: 260px; ">
with
<div id="slider1_container" style="position: relative; top: 0px; left: 0px; width: 332px; height: 260px; ">

waypoints refresh not working when modifying a div

I have a site made of "slides" 100% height.
<div class="slide" id="one">page1</div>
<div class="slide" id="two">page2</div>
<div class="slide" id="three">page3</div>
I use waypoints to perform some animation based on the position of the scroll, and it works fine. The context used is "window" and below an example:
$('#one').waypoint(function(direction)
{
//do something
}, { offset: '75%' });
By the way, in a slide there is a button that modifies the height of an image (it becomes very big), so after the resize the height of the container changes and also the height of the "slide", too.
I need the waypoint to refresh, in order to be raised at the same percentage calculated on the new size of the slide. I tried to do
$.waypoints('refresh');
after the resize, but it seems not working.
Below a piece of my css:
html {
height: 100%;
}
body{
text-align:center;
height:100%;
margin: 0 auto;
overflow-x: hidden;
}
.slide{
height: 100%;
margin: 0 auto;
background: white;
min-height: 700px;
min-width: 1024px;
}
#home {
height: 100%;
margin: 0 auto;
position: relative;
text-align: center;
min-height: 800px;
}
Can someone help me?