How to disable Vue transition-group waiting for browser tab to be selected? - vue.js

I have a list generated in a v-for loop. Wrapped around it is a transition-group like so:
<transition-group name="list">
<tr v-for="item in items" :key="item.key" class="list-item">
<td name="foo">{{item.foo}}</td>
<td name="bar">{{item.bar}}</td>
</tr>
</transition-group>
I have set a transition ( in css) on element deletion and creation:
.list-enter-active, .list-leave-active {
transition: all 0.5s;
}
.list-enter {
background-color: green;
}
.list-leave-to {
background-color: red;
}
(Flash red before removing from the list. Flash green after inserting into the list)
The problem is that, if another tab on the browser is selected, and update on a list is made, the transition waits for the tab where Vue is to be selected. And only then transition gets executed.
I would want for transition animation to execute real time and, if the browser tab at the time of the update of the list is not selected, then execute run (or ignore) the animation anyway.
Is there a way to do that?
UPDATE:
Created issue on Vue GitHub repo - https://github.com/vuejs/vue/issues/9890

Got an answer to the issue created in the GitHub repo - link to answer. Will post it here in case if someone stumbles upon the same problem:
Unfortunately, this is due to how browsers trigger the transitioned events when tabs are inactive.
If this is problematic for the kind of animation you are doing, you should switch instead to something that uses JS instead of CSS animations. That way, you can end the animation calling the done callback with js hooks: https://v2.vuejs.org/v2/guide/transitions.html#JavaScript-Hooks

Related

How can I implement lazy-loading in the ag-grid filebrowser layout?

I see in this question:
Create tree in angular-grid (ag-grid) with async data loading
that Niall recommends writing a cellRenderer but I'm not sure how that would work. I am guessing there would be a button in the cellRenderer that would trigger the call to get more data, but how would I rebind?
adding rowData directly inside the component watched the updated rowData.
<ag-grid-angular style="width: 100%; height: 400px;" class="ag-theme-balham"
[gridOptions]="gridOptions"
[showToolPanel]="showToolPanel"
[rowData]="rowData">
</ag-grid-angular>
Here's official plunker
Docs

Am I doing this data-menu-top properly? Do I need to change my layout entirely to get this to work?

I'm using data-menu-top on this page because everything is fixed and uses Skrollr to animate the different sections into view. The reason everything is fixed is so that I could do full-page SVGs that cover the height of the page (if you think there's a better way to do this, I would love to be enlightened).
Here's a link to the project development page: http://pman.mindevo.com
The button that appears on the first section has data-menu-top="10300", and this works great on Chrome, but when I try to view it in Firefox (33.0) the link doesn't do anything at all.
I am initializing using this code:
<script type="text/javascript">
setTimeout(function() {
var s = skrollr.init({
});
skrollr.menu.init(s, {
easing: 'quadratic',
duration: function(currentTop, targetTop) {
return 1500;
}
});
}, 1000);
</script>
Am I properly using data-menu-top? Is this a bug I'm not aware of using fixed layouts that are hidden using height?
Do I need to change the layout somehow to accomplish what I want and have it work in Firefox?
So the problem with Firefox was the way that it handles <button> linking. Here's the way the button was in the HTML:
<button class="buy buypotato">
<a data-menu-top="10300" href="#potatoPurchase1" class="purchase-options first-popup-link">
<svg ....etc></svg>
</button>
In Firefox it wasn't doing anything upon clicking, and got me thinking perhaps I'm using "button" HTML element incorrectly. Anyways, changing it to a div like so:
<div class="buy buypotato">
<a data-menu-top="10300" href="#potatoPurchase1" class="purchase-options first-popup-link">
<svg ....etc></svg>
</div>
That allowed Firefox to utilize Skrollr-menu to scroll to where I needed it to.
There might be a better way to do the layout on this, I'm still experimenting.

Durandal: Showing a 'LOADING...' during composition

I can easily show a loading message while the activate method is doing its thing like so:
<div data-bind="compose:ActiveVm">
<div class="text-center" style="margin : 75px">
<i class="fa fa-spinner fa-spin"></i>
</div>
</div>
However if I then update my ActiveVm property with a different viewmodel, the splash content does not show. I understand that the splash content is only designed to show on 'initial' load, but what options do I have for displaying such a message when transitioning from one viewmodel to another?
Note that this composition does not participate in routing...
Update: Related durandal issue here which might be of value to future visitors: https://github.com/BlueSpire/Durandal/issues/414
This begs for a comment of 'what have you tried?' but given that I could see the benefit of this for future users I wanted to throw in my $0.02 -
The splash displays on your screen until Durandal loads up the application and replaces the div with id="applicationHost" 's content with the shell view and the subsequent views that are loaded. If you wanted to make this a re-usable component one thing that you could do is to take that Html.Partial view that is being loaded and create your own view inside of your app folder in your Durandal project.
For example you would create a new HTML view inside of your app folder -
splashpage.html
<div class="splash">
<div class="message">
My app
</div>
<i class="icon-spinner icon-2x icon-spin active"></i>
</div>
And then compose it from your shell -
<div data-bind="if: showSplash">
<!-- ko compose: 'splashpage.html' -->
<!-- /ko -->
</div>
And in your view model you would toggle the observable showSplash whenever you want to show / hide it -
var showSplash = ko.observable(false);
var shell = {
showSplash: showSplash
};
return shell;
And you could call that from your activate methods inside your other view models like this -
define(['shell'], function (shell) {
function activate() {
shell.showSplash(true);
// do something
shell.showSplash(false);
}
});
This sounds to me like a scenario where a custom transition may be useful. When the composition mechanism switches nodes in and out of the DOM, it can use a transition.
This page, under Additional Settings>Transition (about halfway down) describes a custom transition: http://durandaljs.com/documentation/Using-Composition/

Dojo Dijit - Widget within a widget

I am using OneUI which is basically just an extension of the dojo didjit widgets.
I need to put a widget inside a widget.
I am using a div with data-dojo-type="dojo.store.Memory".
I am then setting various elements of this using data-dojo-props.
So for example I have some spans and links set within the data-dojo-props.
These are work and display fine.
I am now trying to add a div which itself is a widget. So I've added the div and within this div I am setting the data-dojo-type as a HoverHelpToolTip and setting some other elements such as an onmouseover and some data-dojo-props.
Essentially what should happen is that a hover help tooltip should pop up on mouse over - but it isn't working at all.
So I suppose my question here is how do I correctly nest one widget within another?
Thanks
Sample Code
I am declaring it as follows...
<div data-dojo-id="store1819454249457680384" data-dojo-type="dojo.store.Memory" id="store1819454249457680384" data-dojo-props="data:[{"Name":"<!--o3nv--> ","id":1,"gender":"Female","ActionColumn":"<span class=\"actions\" ><a href=\"...\" onclick=\"...\" title=\"Click here to edit this item\" >Edit<\/a><span class=\"linksDivider\" > | <\/span><a href=\"#\" onclick=\"...\" title=\"Click here to delete this item\" >Delete<\/a><\/span>","Person.firstName":"werrwewre",
<!-- This is the start of the code in question -->
"HelpColumn":"<div class=\"hiddenHelpDialog\" data-dojo- props=\"forceFocus:true,connectId:['helpAnchor_rowHelp10309939']\" data-dojo- type=\"idx\/oneui\/HoverHelpTooltip\" id=\"rowHelp10309939\" style=\"text-align: left; position:relative; display:none\" widgetid=\"rowHelp10309939\" ><div class=\"helpDivDialog\" ><p class=\"helpFieldHeadingDialog\" >\u00a0<\/p><p class=\"helpDescriptionTextDialog\" >BLAH BLAH BLAH BLAH<\/p><\/div><\/div><a class=\"openHelpLink openHelpLinkDisplayField\" id=\"helpAnchor_rowHelp10309939\" onmouseover=\"idx.oneui.HoverHelpTooltip.defaultPosition=['above']\" ><\/a>"}]" ><!-- comment--></div>
It produces the following HTML which works correctly apart from the HoverHelpTip not appearing. The onmouseover is firing. Its alsmot like the widget isn't registered with dojo?!?!
<div widgetid="rowHelp1248193624" style="text-align: left; position:relative; display:none" id="rowHelp1248193624" data-dojo-type="idx/oneui/HoverHelpTooltip" data-dojo-props="forceFocus:true,connectId:'helpAnchor_rowHelp1248193624'" class="hiddenHelpDialog"> <div class="helpDivDialog">
<p class="helpFieldHeadingDialog"> </p>
<p class="helpDescriptionTextDialog">BLAH BLAH BLAH BLAH</p></div></div>
<a class="openHelpLink openHelpLinkDisplayField" id="helpAnchor_rowHelp1248193624" onmouseover="idx.oneui.HoverHelpTooltip.defaultPosition=['above'];">
<span class="hidden"> </span></a>
I fixed this by calling parser.instantiate(node) on the DOM Node when dojo is ready.
I dont know why but for some reason the widget was not being picked up/parsed.
I check dijit.registry and there was no mention of it and a lookup using dijit.byid returned undefined.
Explicitly instantiating the node worked however.
Anyone got any idea why????

dojox.Standby not showing until .hide() is called

I'm trying to use a dojox.widget.Standby. I want the standby to display whilst some other code is executing, and then hide once complete. However my standby only seems to display when I call standby.hide(). Code below:
standby = new dojox.widget.Standby({
target : "map-id"
});
<div id="map-id" class="centerPanel"
data-dojo-type="dijit.layout.ContentPane"
data-dojo-props="region: 'center', style: 'width: 1300px;'">
<span id="toolbar"></span>
<div id="co-ords" style="position:absolute; bottom:0px; z-index:1000; font-size:8; font-weight:bold; background-color: #FFFFFF"></div>
</div>
Anyone know what's going on? I'm also struggling to catch the onShow event using dojo.connect...
dojo.connect(standby, "onShow", function(){
console.log("standby onShow");
})
Thanks!
Update - calling standby.hide() shows my widget in FireFox but not Chrome
Does the code wrapped in between the show and hide calls happen to be synchronous xhrget/xhrpost ajax calls? When sync=true all browser action stops completely, and thus the standby animation would only show and hide really quick after the ajax calls are finished, at the same time you are calling .hide(). If so and you have multiple calls that need to act synchronously, then you can just make them async and chain them together in their response functions.
I have found that I always need to add the following line when creating the standby widget:
dojo.body().appendChild(standby.domNode);
If you really need the synchoronous call, instead of using standby, you can try doing this way...
dojo.byId('loading_status').innerHTML='Loading 0%...';
sync_ajax_call_1();
dojo.byId('loading_status').innerHTML='Loading 25%...';
sync_ajax_call_2();
dojo.byId('loading_status').innerHTML='Loading 50%...';
sync_ajax_call_3();
dojo.byId('loading_status').innerHTML='Loading 75%...';
sync_ajax_call_4();
dojo.byId('loading_status').innerHTML='Loading 100%...';
dojo.byId can also be substituted with dom.byId or $ (in jquery) or getElementById
also make-sure that map-id element has also height grater than zero at the time of the standy startup.
It's common a standby to work correctly, but it is inside an element that has no height or no width or none of the two, so finally nothing is showing up.