1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-09-08 13:36:48 +00:00
TiddlyWiki5/core/modules/macros/list/listviews/classic.js
2012-10-25 22:20:27 +01:00

82 lines
2.6 KiB
JavaScript

/*\
title: $:/core/modules/macros/list/listviews/classic.js
type: application/javascript
module-type: listview
Views the list as a linear sequence
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
function ClassicListView(listMacro) {
this.listMacro = listMacro;
}
ClassicListView.prototype.insert = function(index) {
var listElementNode = this.listMacro.listFrame.children[index],
targetElement = listElementNode.domNode;
// Get the current height of the tiddler
var currHeight = targetElement.offsetHeight;
// Animate the closure
$tw.utils.setStyle(targetElement,[
{transition: ""},
{transformOrigin: "0% 0%"},
{transform: "translateX(" + window.innerWidth + "px)"},
{opacity: "0.0"},
{height: "0px"}
]);
$tw.utils.forceLayout(targetElement);
$tw.utils.setStyle(targetElement,[
{transition: $tw.utils.roundTripPropertyName("transform") + " " + $tw.config.preferences.animationDurationMs + " ease-in-out, " +
"opacity " + $tw.config.preferences.animationDurationMs + " ease-out, " +
"height " + $tw.config.preferences.animationDurationMs + " ease-in-out"},
{transform: "translateX(0px)"},
{opacity: "1.0"},
{height: currHeight + "px"}
]);
};
ClassicListView.prototype.remove = function(index) {
var listElementNode = this.listMacro.listFrame.children[index],
targetElement = listElementNode.domNode;
// Get the current height of the tiddler
var currHeight = targetElement.offsetHeight;
// Put a wrapper around the dom node we're closing
var wrapperElement = document.createElement("div");
targetElement.parentNode.insertBefore(wrapperElement,targetElement);
wrapperElement.appendChild(targetElement);
// Attach an event handler for the end of the transition
wrapperElement.addEventListener($tw.browser.transitionEnd,function(event) {
if(wrapperElement.parentNode) {
wrapperElement.parentNode.removeChild(wrapperElement);
}
},false);
// Animate the closure
$tw.utils.setStyle(wrapperElement,[
{transition: $tw.utils.roundTripPropertyName("transform") + " " + $tw.config.preferences.animationDurationMs + " ease-in-out, " +
"opacity " + $tw.config.preferences.animationDurationMs + " ease-out, " +
"height " + $tw.config.preferences.animationDurationMs + " ease-in-out"},
{transformOrigin: "0% 0%"},
{transform: "translateX(0px)"},
{opacity: "1.0"},
{height: currHeight + "px"}
]);
$tw.utils.forceLayout(wrapperElement);
$tw.utils.setStyle(wrapperElement,[
{transform: "translateX(-" + window.innerWidth + "px)"},
{opacity: "0.0"},
{height: "0px"}
]);
// Returning true causes the DOM node not to be deleted
return true;
};
exports["classic"] = ClassicListView;
})();