Commit ac909326 authored by Roque's avatar Roque

erp5_drone_simulator: game core changes

- 2 new Drone API (AaºileFixe and DroneLog)
- new drone API methods
- game parameter use compareFlights property
- print log flight path in color (mapmanager)
- update libraries
parent e498136c
......@@ -9,12 +9,12 @@
<script src="jiodev.js" type="text/javascript"></script>
<script src ="renderjs.js"></script>
<script type="text/javascript" src="./js/libraries/split.min.js"></script>
<script type="text/javascript" src="./js/libraries/babylon.min.js"></script>
<script type="text/javascript" src="./js/libraries/babylon.js"></script>
<script type="text/javascript" src="./js/libraries/babylon.gui.js"></script>
<script type="text/javascript" src="./js/libraries/require.js"></script>
<script src="./js/DroneAPI.js"></script>
<script src="./js/DroneLogAPI.js"></script>
<script src="./js/DroneAaileFixeAPI.js"></script>
<script src="./js/DroneManager.js"></script>
<script src="./js/GameManager.js"></script>
<script src="./js/MapManager.js"></script>
......
......@@ -59,13 +59,6 @@ var DroneAPI = /** @class */ (function () {
if (["gameTime", "mapSize", "teamSize", "derive", "meteo", "initialHumanAreaPosition"].includes(name))
return this._gameManager.gameParameter[name];
};
DroneAPI.prototype.getMapInfos = function () {
return {
width: GAMEPARAMETERS.mapSize.width,
depth: GAMEPARAMETERS.mapSize.depth,
height: GAMEPARAMETERS.mapSize.height
};
};
DroneAPI.prototype._isWithinDroneView = function (drone_position, element_position) {
// Check if element is under the drone cone-view
var angle = GAMEPARAMETERS.drone.viewAngle ? GAMEPARAMETERS.drone.viewAngle : 60,
......@@ -123,5 +116,42 @@ var DroneAPI = /** @class */ (function () {
}, 2000);
}
};
DroneAPI.prototype.getDirectionFromCoordinates = function (x, y, z, drone_position) {
if(isNaN(x) || isNaN(y) || isNaN(z)){
throw new Error('Target coordinates must be numbers');
}
x -= drone_position.x;
y -= drone_position.y;
z -= drone_position.z;
if (this._team == "R")
y = -y;
return {
x: x,
y: y,
z: z
};
};
DroneAPI.prototype.setAltitude = function (altitude) {
//TODO
return;
};
DroneAPI.prototype.getInitialAltitude = function () {
return 0;
};
DroneAPI.prototype.getAltitudeAbs = function () {
return 0;
};
DroneAPI.prototype.getMinHeight = function () {
return 9;
};
DroneAPI.prototype.getMaxHeight = function () {
return 220;
};
DroneAPI.prototype.getDroneAI = function () {
return null;
};
DroneAPI.prototype.getMaxSpeed = function () {
return GAMEPARAMETERS.drone.maxSpeed;
};
return DroneAPI;
}());
......@@ -6,13 +6,9 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>require.js</string> </value>
<value> <string>DroneAaileFixeAPI.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
/// <reference path="./GameManager.ts" />
var DroneLogAPI = /** @class */ (function () {
//*************************************************** CONSTRUCTOR **************************************************
function DroneLogAPI(gameManager, team, flight_parameters) {
this._gameManager = gameManager;
this._team = team;
this._flight_parameters = flight_parameters;
}
Object.defineProperty(DroneLogAPI.prototype, "team", {
//*************************************************** ACCESSOR *****************************************************
get: function () {
if (this._team == "L")
return this._gameManager.teamLeft;
else if (this._team == "R")
return this._gameManager.teamRight;
},
enumerable: true,
configurable: true
});
//*************************************************** FUNCTIONS ****************************************************
//#region ------------------ Internal
DroneLogAPI.prototype.internal_sendMsg = function (msg, to) {
var _this = this;
_this._gameManager.delay(function () {
if (to < 0) {
// Send to all drones
_this.team.forEach(function (drone) {
if (drone.infosMesh) {
try {
drone.onGetMsg(msg);
}
catch (error) {
console.warn('Drone crashed on sendMsg due to error:', error);
drone._internal_crash();
}
}
});
}
else {
// Send to specific drone
if (drone.infosMesh) {
try {
_this.team[to].onGetMsg(msg);
}
catch (error) {
console.warn('Drone crashed on sendMsg due to error:', error);
_this.team[to]._internal_crash();
}
}
}
}, GAMEPARAMETERS.latency.communication);
};
//#endregion
//#region ------------------ Accessible from AI
DroneLogAPI.prototype.log = function (msg) {
console.log("API say : " + msg);
};
DroneLogAPI.prototype.getGameParameter = function (name) {
if (["gameTime", "mapSize", "teamSize", "derive", "meteo", "initialHumanAreaPosition"].includes(name))
return this._gameManager.gameParameter[name];
};
DroneLogAPI.prototype._isWithinDroneView = function (drone_position, element_position) {
// Check if element is under the drone cone-view
var angle = GAMEPARAMETERS.drone.viewAngle ? GAMEPARAMETERS.drone.viewAngle : 60,
radius = drone_position.z * Math.tan(angle/2 * Math.PI/180),
distance = (drone_position.x - element_position.x) * (drone_position.x - element_position.x) +
(drone_position.y - element_position.y) * (drone_position.y - element_position.y);
if (distance < (radius*radius))
return true;
return false;
};
DroneLogAPI.prototype._getProbabilityOfDetection = function (drone_position) {
var h = drone_position.z,
km = GAMEPARAMETERS.meteo;
prob = 20 * (1 + (110-h)/25) * km;
return prob;
};
DroneLogAPI.prototype.isHumanPositionSpottedCalculation = function (drone) {
var context = this,
result = false,
drone_position = drone.infosMesh.position;
//swap axes back
drone_position = {
x: drone_position.x,
y: drone_position.z,
z: drone_position.y
};
context._gameManager.teamRight.forEach(function (human) {
if (human.infosMesh && context._isWithinDroneView(drone_position, human.position)) {
var prob = context._getProbabilityOfDetection(drone_position),
random = Math.floor(Math.random()*101);
if (random < prob)
result = true;
}
});
return result;
};
DroneLogAPI.prototype.isHumanPositionSpotted = function (drone) {
var context = this,
human_detected;
if (drone.__is_calculating_human_position !== true) {
drone.__is_calculating_human_position = true;
//human detection is done with the info captured by the drone
//at the moment this method is called
human_detected = context.isHumanPositionSpottedCalculation(drone);
context._gameManager.delay(function () {
drone.__is_calculating_human_position = false;
try {
drone.onCapture(human_detected);
} catch (error) {
console.warn('Drone crashed on capture due to error:', error);
drone._internal_crash();
}
}, 2000);
}
};
DroneLogAPI.prototype.processCoordinates = function (x, y, z) {
if(isNaN(x) || isNaN(y) || isNaN(z)){
throw new Error('Target coordinates must be numbers');
}
return {
x: x,
y: y,
z: z
};
};
DroneLogAPI.prototype.getDroneAI = function () {
return 'function distance(p1, p2) {' +
'var a = p1[0] - p2[0],' +
'b = p1[1] - p2[1];' +
'return Math.sqrt(a * a + b * b);' +
'}' +
'me.onStart = function() {' +
'if (!me.getFlightParameters())' +
'throw "DroneLog API must implement getFlightParameters";' +
'me.flightParameters = me.getFlightParameters();' +
'me.checkpoint_list = me.flightParameters.converted_log_point_list;' +
'me.startTime = new Date();' +
'me.initTimestamp = me.flightParameters.converted_log_point_list[0][3];' +
'me.setTargetCoordinates(me.checkpoint_list[0][0], me.checkpoint_list[0][1], me.checkpoint_list[0][2]);' +
'me.last_checkpoint_reached = -1;' +
'me.setAcceleration(10);' +
'};' +
'me.onUpdate = function () {' +
'var next_checkpoint = me.checkpoint_list[me.last_checkpoint_reached+1];' +
'if (distance([me.position.x, me.position.y], next_checkpoint) < 12) {' +
'var log_elapsed = next_checkpoint[3] - me.initTimestamp,' +
'time_elapsed = new Date() - me.startTime;' +
'if (time_elapsed < log_elapsed) {' +
'me.setDirection(0, 0, 0);' +
'return;' +
'}' +
'if (me.last_checkpoint_reached + 1 === me.checkpoint_list.length - 1) {' +
'me.setTargetCoordinates(me.position.x, me.position.y, me.position.z);' +
'return;' +
'}' +
'me.last_checkpoint_reached += 1;' +
'next_checkpoint = me.checkpoint_list[me.last_checkpoint_reached+1];' +
'me.setTargetCoordinates(next_checkpoint[0], next_checkpoint[1], next_checkpoint[2]);' +
'} else {' +
'me.setTargetCoordinates(next_checkpoint[0], next_checkpoint[1], next_checkpoint[2]);' +
'}' +
'};';
};
DroneLogAPI.prototype.setAltitude = function (altitude) {
return altitude;
};
DroneLogAPI.prototype.getMaxSpeed = function () {
return 3000;
};
DroneLogAPI.prototype.getInitialAltitude = function () {
return 0;
};
DroneLogAPI.prototype.getAltitudeAbs = function () {
return 0;
};
DroneLogAPI.prototype.getMinHeight = function () {
return 0;
};
DroneLogAPI.prototype.getMaxHeight = function () {
return 220;
};
DroneLogAPI.prototype.getFlightParameters = function () {
return this._flight_parameters;
};
return DroneLogAPI;
}());
......@@ -6,13 +6,9 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>split.min.js</string> </value>
<value> <string>DroneLogAPI.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -3,7 +3,9 @@
/// <reference path="./DroneManager.ts" />
/// <reference path="./MapManager.ts" />
/// <reference path="./typings/babylon.gui.d.ts" />
var GAMEPARAMETERS = {};
var GameManager = /** @class */ (function (console) {
var browser_console = console,
console_output = '';
......@@ -47,16 +49,28 @@ var GameManager = /** @class */ (function (console) {
this.finish_deferred = null;
if (!simulation_speed) { simulation_speed = 5; }
this._max_step_animation_frame = simulation_speed;
this._last_position_drawn = [];
this._log_count = [];
this._flight_log = [];
if (GAMEPARAMETERS.compareFlights) {
for (var count = 0; count < GAMEPARAMETERS.teamSize; count++) {
this._flight_log[count] = [];
this._log_count[count] = 0;
this._last_position_drawn[count] = null;
}
this._colors = [
new BABYLON.Color3(255, 165, 0),
new BABYLON.Color3(0, 0, 255),
new BABYLON.Color3(255, 0, 0),
new BABYLON.Color3(0, 255, 0)
];
}
this.APIs_dict = {
DroneAaileFixeAPI: DroneAaileFixeAPI,
DroneLogAPI: DroneLogAPI,
DroneAPI: DroneAPI
};
// ----------------------------------- CODE ZONES AND PARAMS
// JIO : AI
// XXX
DroneManager.jIOstorage = jIO.createJIO({
"type": "query",
"sub_storage": {
"type": "indexeddb",
"database": "Drones_infos_storage"
}
});
// Timing display
this._timeDisplay = document.getElementById("timingDisplay");
......@@ -66,18 +80,11 @@ var GameManager = /** @class */ (function (console) {
GameManager.prototype.run = function() {
var gadget = this;
return DroneManager.jIOstorage.allDocs()
.push(function (result) {
var promise_list = [], i;
for (i = 0; i < result.data.total_rows; i += 1) {
promise_list.push(DroneManager.jIOstorage.remove(result.data.rows[i].id));
}
return RSVP.all(promise_list);
})
.push(function () {
return gadget._init();
})
return gadget._init()
.push(function () {
if (GAMEPARAMETERS.compareFlights) {
return gadget._flight_log;
}
return gadget._final_score;
});
};
......@@ -268,6 +275,51 @@ var GameManager = /** @class */ (function (console) {
if (update_dom) {
this._timeDisplay.textContent = this._formatTimeToMinutesAndSeconds(this._game_duration);
}
if (GAMEPARAMETERS.compareFlights) {
for (var count = 0; count < GAMEPARAMETERS.teamSize; count++) {
if (this._teamLeft[count]._controlMesh) {
var drone_position_x = this._teamLeft[count]._controlMesh.position.x,
drone_position_z = this._teamLeft[count]._controlMesh.position.y,
drone_position_y = this._teamLeft[count]._controlMesh.position.z;
if (GAMEPARAMETERS.compareFlights.log) {
if (this._log_count[count] === 0 || this._game_duration / this._log_count[count] > 1) {
this._log_count[count] += GAMEPARAMETERS.compareFlights.log_interval_time;
//convert x-y coordinates into latitud-longitude
var lon = drone_position_x + GAMEPARAMETERS.compareFlights.map_width / 2;
lon = lon / 1000;
lon = lon * (GAMEPARAMETERS.compareFlights.MAX_X - GAMEPARAMETERS.compareFlights.MIN_X) + GAMEPARAMETERS.compareFlights.MIN_X;
lon = lon / (GAMEPARAMETERS.compareFlights.map_width / 360.0) - 180;
var lat = drone_position_y + GAMEPARAMETERS.compareFlights.map_height / 2;
lat = lat / 1000;
lat = lat * (GAMEPARAMETERS.compareFlights.MAX_Y - GAMEPARAMETERS.compareFlights.MIN_Y) + GAMEPARAMETERS.compareFlights.MIN_Y;
lat = 90 - lat / (GAMEPARAMETERS.compareFlights.map_height / 180.0);
this._flight_log[count].push([lat, lon, drone_position_z]);
}
}
if (GAMEPARAMETERS.compareFlights.draw) {
//draw drone position every second
if (this._last_position_drawn[count] !== seconds) {
this._last_position_drawn[count] = seconds;
var position_obj = BABYLON.MeshBuilder.CreateSphere("obs_" + seconds, {
'diameterX': 3.5,
'diameterY': 3.5,
'diameterZ': 3.5
}, this._scene);
position_obj.position = new BABYLON.Vector3(drone_position_x, drone_position_z, drone_position_y);
position_obj.scaling = new BABYLON.Vector3(3.5, 3.5, 3.5);
var material = new BABYLON.StandardMaterial(this._scene);
material.alpha = 1;
var color = new BABYLON.Color3(255, 0, 0);
if (this._colors[count]) {
color = this._colors[count];
}
material.diffuseColor = color;
position_obj.material = material;
}
}
}
}
}
};
/**
* Function used to check collision between 2 drones
......@@ -275,6 +327,9 @@ var GameManager = /** @class */ (function (console) {
* @param drone2
*/
GameManager.prototype._checkCollision = function (drone, other) {
if (GAMEPARAMETERS.compareFlights) {
return;
}
if (drone.colliderMesh && other.colliderMesh
&& drone.colliderMesh.intersectsMesh(other.colliderMesh, false)) {
var angle = Math.acos(BABYLON.Vector3.Dot(drone.worldDirection, other.worldDirection) / (drone.worldDirection.length() * other.worldDirection.length()));
......@@ -326,6 +381,9 @@ var GameManager = /** @class */ (function (console) {
* @param obstacle
*/
GameManager.prototype._checkCollisionWithObstacle = function (drone, obstacle) {
if (GAMEPARAMETERS.compareFlights) {
return;
}
if (obstacle.obsType === "boat") {
return this._checkCollisionWithSpecialObstacle(drone, obstacle);
}
......@@ -360,7 +418,7 @@ var GameManager = /** @class */ (function (console) {
*/
GameManager.prototype._checkCollisionWithFloor = function (drone) {
if (drone.infosMesh) {
if (drone.position.z < 9) {
if (drone.position.z < drone.getMinHeight()) {
return true;
}
}
......@@ -372,7 +430,7 @@ var GameManager = /** @class */ (function (console) {
*/
GameManager.prototype._checkDroneOut = function (drone) {
if (drone.position !== null) {
if (drone.position.z > 100) {
if (drone.position.z > drone.getMaxHeight()) {
return true;
}
return BABYLON.Vector3.Distance(drone.position, BABYLON.Vector3.Zero()) > GAMEPARAMETERS.distances.control;
......@@ -409,9 +467,13 @@ var GameManager = /** @class */ (function (console) {
return parameter;
};
GameManager.prototype._setSpawnDrone = function (x, y, z, index, api, code, team) {
var default_drone_AI = api.getDroneAI();
if (default_drone_AI) {
code = default_drone_AI;
}
var ctx = this, base, code_eval = "let drone = new DroneManager(ctx._scene, "
+ index + ', "' + team + '", api);'
+ "let droneMe = function(NativeDate, me, Math, window, DroneManager, GameManager, DroneAPI, BABYLON, GAMEPARAMETERS) {"
+ "let droneMe = function(NativeDate, me, Math, window, DroneManager, GameManager, DroneAPI, DroneLogAPI, DroneAaileFixeAPI, BABYLON, GAMEPARAMETERS) {"
+ "var start_time = (new Date(2070, 0, 0, 0, 0, 0, 0)).getTime();"
+ "Date.now = function () {return start_time + drone._tick * 1000/60;}; "
+ "function Date() {if (!(this instanceof Date)) {throw new Error('Missing new operator');} "
......@@ -425,7 +487,6 @@ var GameManager = /** @class */ (function (console) {
}
base = code_eval;
code_eval += code + "}; droneMe(Date, drone, Math, {});";
//code_eval += code + "}; droneMe(drone, Math, {});";
if (team == "R") {
base += "};ctx._teamRight.push(drone)";
code_eval += "ctx._teamRight.push(drone)";
......@@ -484,7 +545,13 @@ var GameManager = /** @class */ (function (console) {
}
else {
position_list.push(position);
this._setSpawnDrone(position.x, position.y, position.z, i, api, code, team);
var lAPI = api;
if (randomSpawn.types) {
if (randomSpawn.types[i] in this.APIs_dict) {
lAPI = new this.APIs_dict[randomSpawn.types[i]](this, "L", GAMEPARAMETERS.compareFlights);
}
}
this._setSpawnDrone(position.x, position.y, position.z, i, lAPI, code, team);
}
}
}
......@@ -552,7 +619,11 @@ var GameManager = /** @class */ (function (console) {
}
//cap camera distance to 1km
if (radius > 800) radius = 800;
camera = new BABYLON.ArcRotateCamera("camera", x_rotation, 1.25, radius, new BABYLON.Vector3(vector_x, 0, vector_y), this._scene);
var target = new BABYLON.Vector3(vector_x, 0, vector_y);
if (GAMEPARAMETERS.compareFlights) {
target = BABYLON.Vector3.Zero();
}
camera = new BABYLON.ArcRotateCamera("camera", x_rotation, 1.25, radius, target, this._scene);
camera.wheelPrecision = 10;
camera.attachControl(this._scene.getEngine().getRenderingCanvas());
camera.maxz = 40000
......
......@@ -116,6 +116,12 @@ var MapManager = /** @class */ (function () {
newObj.rotation = new BABYLON.Vector3(obs.rotation.x * convertion, obs.rotation.y * convertion, obs.rotation.z * convertion);
if ("scale" in obs)
newObj.scaling = new BABYLON.Vector3(obs.scale.x, obs.scale.y, obs.scale.z);
if ("color" in obs) {
var material = new BABYLON.StandardMaterial(scene);
material.alpha = 1;
material.diffuseColor = new BABYLON.Color3(obs.color.r, obs.color.g, obs.color.b);
newObj.material = material;
}
_this._obstacles.push(newObj);
});
}
......
......@@ -6,13 +6,9 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
<value> <string>babylon.min.js</string> </value>
<value> <string>babylon.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
/*! Split.js - v1.3.5 */
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):e.Split=t()}(this,function(){"use strict";var e=window,t=e.document,n="addEventListener",i="removeEventListener",r="getBoundingClientRect",s=function(){return!1},o=e.attachEvent&&!e[n],a=["","-webkit-","-moz-","-o-"].filter(function(e){var n=t.createElement("div");return n.style.cssText="width:"+e+"calc(9px)",!!n.style.length}).shift()+"calc",l=function(e){return"string"==typeof e||e instanceof String?t.querySelector(e):e};return function(u,c){function z(e,t,n){var i=A(y,t,n);Object.keys(i).forEach(function(t){return e.style[t]=i[t]})}function h(e,t){var n=B(y,t);Object.keys(n).forEach(function(t){return e.style[t]=n[t]})}function f(e){var t=E[this.a],n=E[this.b],i=t.size+n.size;t.size=e/this.size*i,n.size=i-e/this.size*i,z(t.element,t.size,this.aGutterSize),z(n.element,n.size,this.bGutterSize)}function m(e){var t;this.dragging&&((t="touches"in e?e.touches[0][b]-this.start:e[b]-this.start)<=E[this.a].minSize+M+this.aGutterSize?t=E[this.a].minSize+this.aGutterSize:t>=this.size-(E[this.b].minSize+M+this.bGutterSize)&&(t=this.size-(E[this.b].minSize+this.bGutterSize)),f.call(this,t),c.onDrag&&c.onDrag())}function g(){var e=E[this.a].element,t=E[this.b].element;this.size=e[r]()[y]+t[r]()[y]+this.aGutterSize+this.bGutterSize,this.start=e[r]()[G]}function d(){var t=this,n=E[t.a].element,r=E[t.b].element;t.dragging&&c.onDragEnd&&c.onDragEnd(),t.dragging=!1,e[i]("mouseup",t.stop),e[i]("touchend",t.stop),e[i]("touchcancel",t.stop),t.parent[i]("mousemove",t.move),t.parent[i]("touchmove",t.move),delete t.stop,delete t.move,n[i]("selectstart",s),n[i]("dragstart",s),r[i]("selectstart",s),r[i]("dragstart",s),n.style.userSelect="",n.style.webkitUserSelect="",n.style.MozUserSelect="",n.style.pointerEvents="",r.style.userSelect="",r.style.webkitUserSelect="",r.style.MozUserSelect="",r.style.pointerEvents="",t.gutter.style.cursor="",t.parent.style.cursor=""}function S(t){var i=this,r=E[i.a].element,o=E[i.b].element;!i.dragging&&c.onDragStart&&c.onDragStart(),t.preventDefault(),i.dragging=!0,i.move=m.bind(i),i.stop=d.bind(i),e[n]("mouseup",i.stop),e[n]("touchend",i.stop),e[n]("touchcancel",i.stop),i.parent[n]("mousemove",i.move),i.parent[n]("touchmove",i.move),r[n]("selectstart",s),r[n]("dragstart",s),o[n]("selectstart",s),o[n]("dragstart",s),r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.MozUserSelect="none",r.style.pointerEvents="none",o.style.userSelect="none",o.style.webkitUserSelect="none",o.style.MozUserSelect="none",o.style.pointerEvents="none",i.gutter.style.cursor=j,i.parent.style.cursor=j,g.call(i)}function v(e){e.forEach(function(t,n){if(n>0){var i=F[n-1],r=E[i.a],s=E[i.b];r.size=e[n-1],s.size=t,z(r.element,r.size,i.aGutterSize),z(s.element,s.size,i.bGutterSize)}})}function p(){F.forEach(function(e){e.parent.removeChild(e.gutter),E[e.a].element.style[y]="",E[e.b].element.style[y]=""})}void 0===c&&(c={});var y,b,G,E,w=l(u[0]).parentNode,D=e.getComputedStyle(w).flexDirection,U=c.sizes||u.map(function(){return 100/u.length}),k=void 0!==c.minSize?c.minSize:100,x=Array.isArray(k)?k:u.map(function(){return k}),L=void 0!==c.gutterSize?c.gutterSize:10,M=void 0!==c.snapOffset?c.snapOffset:30,O=c.direction||"horizontal",j=c.cursor||("horizontal"===O?"ew-resize":"ns-resize"),C=c.gutter||function(e,n){var i=t.createElement("div");return i.className="gutter gutter-"+n,i},A=c.elementStyle||function(e,t,n){var i={};return"string"==typeof t||t instanceof String?i[e]=t:i[e]=o?t+"%":a+"("+t+"% - "+n+"px)",i},B=c.gutterStyle||function(e,t){return n={},n[e]=t+"px",n;var n};"horizontal"===O?(y="width","clientWidth",b="clientX",G="left","paddingLeft"):"vertical"===O&&(y="height","clientHeight",b="clientY",G="top","paddingTop");var F=[];return E=u.map(function(e,t){var i,s={element:l(e),size:U[t],minSize:x[t]};if(t>0&&(i={a:t-1,b:t,dragging:!1,isFirst:1===t,isLast:t===u.length-1,direction:O,parent:w},i.aGutterSize=L,i.bGutterSize=L,i.isFirst&&(i.aGutterSize=L/2),i.isLast&&(i.bGutterSize=L/2),"row-reverse"===D||"column-reverse"===D)){var a=i.a;i.a=i.b,i.b=a}if(!o&&t>0){var c=C(t,O);h(c,L),c[n]("mousedown",S.bind(i)),c[n]("touchstart",S.bind(i)),w.insertBefore(c,s.element),i.gutter=c}0===t||t===u.length-1?z(s.element,s.size,L/2):z(s.element,s.size,L);var f=s.element[r]()[y];return f<s.minSize&&(s.minSize=f),t>0&&F.push(i),s}),o?{setSizes:v,destroy:p}:{setSizes:v,getSizes:function(){return E.map(function(e){return e.size})},collapse:function(e){if(e===F.length){var t=F[e-1];g.call(t),o||f.call(t,t.size-t.bGutterSize)}else{var n=F[e];g.call(n),o||f.call(n,n.aGutterSize)}},destroy:p}}});
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment