我正在使用打包库。
问题是关于fit
方法的第二个参数。该文件说它应该是一个元素,但我不知道“元素”是什么意思。
以下链接是我的问题的一个示例。
当我单击调整大小按钮时,fit
似乎不起作用。如果它正常工作,当我调整“post 1”的大小时,“post 2”应该转到第二行而不是重叠。
以下链接是我的意思的一个例子,但我希望通过按钮来触发。
http://jsfiddle.net/9Q5sZ/3/检查这个小提琴
if (isLarge) {
$("div#container").packery('fit', div[0]);
}
提供目标元素使用 div[0]。
变量“div”是 Jquery 输出对象,在运行时它将是一个对象数组
div: jQuery.fn.init[1]
0: div.post.large
context: button.resize
length: 1
prevObject: jQuery.fn.init[1]
__proto__: Object[0]
正如您所看到的其他参数,如上下文、原型、长度等。但是您的 Packery 插件只需要精确的 div 对象(此对象由包装文档中的元素表示)。因此 div[0] 将提供精确的 div 对象
div[0]: div.post
accessKey: ""
align: ""
attributes: NamedNodeMap
baseURI: "http://fiddle.jshell.net/9Q5sZ/3/show/"
childElementCount: 2
childNodes: NodeList[5]
children: HTMLCollection[2]
classList: DOMTokenList[1]
className: "post"
clientHeight: 100
clientLeft: 3
clientTop: 3
clientWidth: 211
contentEditable: "inherit"
dataset: DOMStringMap
dir: ""
draggable: false
firstChild: text
firstElementChild: button.resize
hidden: false
id: ""
innerHTML: "↵ <button class="resize">resize</button>↵ <div>post 1</div>↵ "
innerText: "resize↵post 1↵"
isContentEditable: false
lang: ""
lastChild: text
lastElementChild: div
localName: "div"
namespaceURI: "http://www.w3.org/1999/xhtml"
nextElementSibling: div.post
nextSibling: text
nodeName: "DIV"
nodeType: 1
nodeValue: null
offsetHeight: 106
offsetLeft: 0
offsetParent: div#container
offsetTop: 0
offsetWidth: 217
onabort: null
onbeforecopy: null
onbeforecut: null
onbeforepaste: null
onblur: null
oncancel: null
oncanplay: null
oncanplaythrough: null
onchange: null
onclick: null
onclose: null
oncontextmenu: null
oncopy: null
oncuechange: null
oncut: null
ondblclick: null
ondrag: null
ondragend: null
ondragenter: null
ondragleave: null
ondragover: null
ondragstart: null
ondrop: null
ondurationchange: null
onemptied: null
onended: null
onerror: null
onfocus: null
oninput: null
oninvalid: null
//Object continues