Skip to content

Commit

Permalink
fix autoresize
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanocudini committed Sep 10, 2018
1 parent 6e643c8 commit 83c6d63
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 18 deletions.
7 changes: 3 additions & 4 deletions TODO
Expand Up @@ -14,9 +14,8 @@ Tasks found in: src/leaflet-search.js
[Line: 615] [low] //TODO implements autype without selection(useful for mobile device)
[Line: 745] [low] //TODO _recordsFromLayer must return array of objects, formatted from _formatData
[Line: 766] [low] //TODO refact!
[Line: 780] [low] //TODO refact _handleAutoresize now is not accurate
[Line: 948] [low] //TODO refact animate() more smooth! like this: http://goo.gl/DDlRs
[Line: 972] [low] //TODO use create event 'animateEnd' in L.Control.Search.Marker
[Line: 956] [low] //TODO refact animate() more smooth! like this: http://goo.gl/DDlRs
[Line: 980] [low] //TODO use create event 'animateEnd' in L.Control.Search.Marker
[Line: 18] [med] //FIXME option condition problem {autoCollapse: true, markerLocation: true} not show location
[Line: 19] [med] //FIXME option condition problem {autoCollapse: false }
[Line: 879] [med] //FIXME autoCollapse option hide self._markerSearch before visualized!!
[Line: 887] [med] //FIXME autoCollapse option hide self._markerSearch before visualized!!
2 changes: 1 addition & 1 deletion dist/leaflet-search.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/leaflet-search.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/leaflet-search.mobile.min.css
@@ -1,5 +1,5 @@
/*
* Leaflet Control Search v2.9.0 - 2018-05-16
* Leaflet Control Search v2.9.5 - 2018-09-10
*
* Copyright 2018 Stefano Cudini
* stefano.cudini@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-search.mobile.src.css
@@ -1,5 +1,5 @@
/*
* Leaflet Control Search v2.9.0 - 2018-05-16
* Leaflet Control Search v2.9.5 - 2018-09-10
*
* Copyright 2018 Stefano Cudini
* stefano.cudini@gmail.com
Expand Down
2 changes: 1 addition & 1 deletion dist/leaflet-search.src.css
@@ -1,5 +1,5 @@
/*
* Leaflet Control Search v2.9.0 - 2018-05-16
* Leaflet Control Search v2.9.5 - 2018-09-10
*
* Copyright 2018 Stefano Cudini
* stefano.cudini@gmail.com
Expand Down
22 changes: 15 additions & 7 deletions dist/leaflet-search.src.js
@@ -1,5 +1,5 @@
/*
* Leaflet Control Search v2.9.0 - 2018-05-16
* Leaflet Control Search v2.9.5 - 2018-09-10
*
* Copyright 2018 Stefano Cudini
* stefano.cudini@gmail.com
Expand Down Expand Up @@ -792,13 +792,21 @@ L.Control.Search = L.Control.extend({
}
},

_handleAutoresize: function() { //autoresize this._input
//TODO refact _handleAutoresize now is not accurate
if (this._input.style.maxWidth != this._map._container.offsetWidth) //If maxWidth isn't the same as when first set, reset to current Map width
this._input.style.maxWidth = L.DomUtil.getStyle(this._map._container, 'width');
_handleAutoresize: function() {
var maxWidth;

if(this.options.autoResize && (this._container.offsetWidth + 45 < this._map._container.offsetWidth))
this._input.size = this._input.value.length<this._inputMinSize ? this._inputMinSize : this._input.value.length;
if (this._input.style.maxWidth !== this._map._container.offsetWidth) {
maxWidth = L.DomUtil.getStyle(this._map._container, 'width');
maxWidth = parseInt(maxWidth);
// other side margin + padding + width border + width search-button + width search-cancel
maxWidth -= 10 + 20 + 1 + 30 + 22;

this._input.style.maxWidth = maxWidth.toString() + 'px';
}

if (this.options.autoResize && (this._container.offsetWidth + 20 < this._map._container.offsetWidth)) {
this._input.size = this._input.value.length < this._inputMinSize ? this._inputMinSize : this._input.value.length;
}
},

_handleArrowSelect: function(velocity) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "leaflet-search",
"version": "2.9.0",
"version": "2.9.5",
"description": "Leaflet Control for searching markers/features by attribute on map or remote searching in jsonp/ajax",
"repository": {
"type": "git",
Expand Down

0 comments on commit 83c6d63

Please sign in to comment.