mirror of
https://bitbucket.org/bellord13/kit.git
synced 2026-11-13 19:06:11 +03:00
fix
This commit is contained in:
+45
-1
@@ -467,14 +467,31 @@ kit.PluginManager.register('align',function(module, exports, require) {
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @class AlignDefault
|
||||
*/
|
||||
const Default = {
|
||||
hAlign: 'center',
|
||||
vAlign: 'top',
|
||||
hDirection: 'center',
|
||||
vDirection: 'top',
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* @param node {HTMLElement|String}
|
||||
* @param parentNode {HTMLElement|String}
|
||||
* @param limiterNode {HTMLElement|String}
|
||||
* @param options {AlignDefault}
|
||||
* @constructor
|
||||
*/
|
||||
var AlignClass = function(node, parentNode, limiterNode = window)
|
||||
var AlignClass = function(node, parentNode, limiterNode = window, options = {})
|
||||
{
|
||||
/**
|
||||
* @type {AlignDefault}
|
||||
*/
|
||||
this.options = Object.assign({}, Default, options);
|
||||
|
||||
this.changeOfDirection = true;
|
||||
this.withinTheScreen = true;
|
||||
this.offset = [0, 0];
|
||||
@@ -495,6 +512,9 @@ kit.PluginManager.register('align',function(module, exports, require) {
|
||||
AlignClass.prototype.setNode = function(node){
|
||||
this.unset();
|
||||
this.node = support.getNode(node);
|
||||
if(!support.isElement(this.node)){
|
||||
console.warn('Align: node is not valid');
|
||||
}
|
||||
this.reset();
|
||||
if(this.node instanceof HTMLElement) {
|
||||
this.node.kit = this.node.kit || {};
|
||||
@@ -512,6 +532,9 @@ kit.PluginManager.register('align',function(module, exports, require) {
|
||||
*/
|
||||
AlignClass.prototype.setParentNode = function(node){
|
||||
this.parentNode = support.getNode(node);
|
||||
if(!support.isElement(this.parentNode)){
|
||||
console.warn('Align: parentNode is not valid');
|
||||
}
|
||||
if(this.__calc) {
|
||||
this.__calc.setParentNode(this.parentNode);
|
||||
}
|
||||
@@ -520,6 +543,9 @@ kit.PluginManager.register('align',function(module, exports, require) {
|
||||
|
||||
AlignClass.prototype.setLimiterNode = function(node){
|
||||
this.limiterNode = support.getNode(node) || window;
|
||||
if(!support.isElement(this.limiterNode) && this.limiterNode !== window){
|
||||
console.warn('Align: limiterNode is not valid');
|
||||
}
|
||||
if(this.__calc) {
|
||||
this.__calc.setLimiterNode(this.limiterNode);
|
||||
}
|
||||
@@ -569,17 +595,35 @@ kit.PluginManager.register('align',function(module, exports, require) {
|
||||
* @return {AlignClass}
|
||||
*/
|
||||
AlignClass.prototype.set = function(hAlign, vAlign, hDirection, vDirection){
|
||||
|
||||
this.options.hAlign = hAlign;
|
||||
this.options.vAlign = vAlign;
|
||||
this.options.hDirection = hDirection;
|
||||
this.options.vDirection = vDirection;
|
||||
|
||||
this.setEx('vertical', vAlign, vDirection);
|
||||
this.setEx('horizontal', hAlign, hDirection);
|
||||
return this;
|
||||
};
|
||||
|
||||
|
||||
AlignClass.prototype.setOptions = function(options){
|
||||
Object.assign(this.options, options);
|
||||
this.setEx('vertical', this.options.vAlign, this.options.vDirection);
|
||||
this.setEx('horizontal', this.options.hAlign, this.options.hDirection);
|
||||
return this;
|
||||
};
|
||||
|
||||
AlignClass.prototype.setVertical = function(align, direction){
|
||||
this.options.vAlign = align;
|
||||
this.options.vDirection = direction;
|
||||
this.setEx('vertical', align, direction);
|
||||
return this;
|
||||
};
|
||||
|
||||
AlignClass.prototype.setHorizontal = function(align, direction){
|
||||
this.options.hAlign = align;
|
||||
this.options.hDirection = direction;
|
||||
this.setEx('horizontal', align, direction);
|
||||
return this;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user