You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Vestride_Shuffle/assets/js/5fbc5cf1.33d854f7.js

1 line
5.8 KiB
JavaScript

"use strict";(globalThis.webpackChunkshuffle_docs=globalThis.webpackChunkshuffle_docs||[]).push([[624],{6348:(e,t,n)=>{n.r(t),n.d(t,{assets:()=>r,contentTitle:()=>l,default:()=>h,frontMatter:()=>i,metadata:()=>d,toc:()=>c});var s=n(1085),o=n(1184);const i={sidebar_position:10},l="API",d={id:"api",title:"API",description:"A list of the methods available to you and what they do.",source:"@site/docs/api.md",sourceDirName:".",slug:"/api",permalink:"/Shuffle/docs/api",draft:!1,unlisted:!1,editUrl:"https://github.com/Vestride/Shuffle/tree/main/apps/website/docs/docs/api.md",tags:[],version:"current",sidebarPosition:10,frontMatter:{sidebar_position:10},sidebar:"tutorialSidebar",previous:{title:"Adding and removing items",permalink:"/Shuffle/docs/adding-removing"},next:{title:"Custom styles",permalink:"/Shuffle/docs/custom-styles"}},r={},c=[{value:"<code>filter(category?, sortObject?)</code>",id:"filtercategory-sortobject",level:2},{value:"<code>sort(sortObject?)</code>",id:"sortsortobject",level:2},{value:"<code>update(options?)</code>",id:"updateoptions",level:2},{value:"<code>layout()</code>",id:"layout",level:2},{value:"<code>add(newItems)</code>",id:"addnewitems",level:2},{value:"<code>disable()</code>",id:"disable",level:2},{value:"<code>enable(isUpdateLayout?)</code>",id:"enableisupdatelayout",level:2},{value:"<code>remove(elements)</code>",id:"removeelements",level:2},{value:"<code>getItemByElement(element)</code>",id:"getitembyelementelement",level:2},{value:"<code>destroy()</code>",id:"destroy",level:2}];function a(e){const t={a:"a",code:"code",h1:"h1",h2:"h2",li:"li",p:"p",ul:"ul",...(0,o.R)(),...e.components};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(t.h1,{id:"api",children:"API"}),"\n",(0,s.jsx)(t.p,{children:"A list of the methods available to you and what they do."}),"\n",(0,s.jsx)(t.h2,{id:"filtercategory-sortobject",children:(0,s.jsx)(t.code,{children:"filter(category?, sortObject?)"})}),"\n",(0,s.jsx)(t.p,{children:"Filters all the shuffle items and then sorts them."}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"category"})," can be a string, array of strings, or a function. Learn more in ",(0,s.jsx)(t.a,{href:"/Shuffle/docs/filters",children:"filters"}),"."]}),"\n",(0,s.jsxs)(t.li,{children:["The ",(0,s.jsx)(t.code,{children:"sortObject"})," is optional, defaulting to the last-used sort object."]}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"sortsortobject",children:(0,s.jsx)(t.code,{children:"sort(sortObject?)"})}),"\n",(0,s.jsx)(t.p,{children:"Sorts the currently filtered shuffle items."}),"\n",(0,s.jsx)(t.p,{children:"Calling sort with an empty object will reset the elements to DOM order."}),"\n",(0,s.jsxs)(t.p,{children:["See the ",(0,s.jsx)(t.a,{href:"/Shuffle/docs/configuration#sorting-object",children:"SortOptions"})," for the available properties."]}),"\n",(0,s.jsx)(t.h2,{id:"updateoptions",children:(0,s.jsx)(t.code,{children:"update(options?)"})}),"\n",(0,s.jsx)(t.p,{children:"Repositions everything. Useful for when dimensions (like the window size) change."}),"\n",(0,s.jsx)(t.p,{children:"You may provide an options object containing the following properties:"}),"\n",(0,s.jsxs)(t.ul,{children:["\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"recalculateSizes"}),": Whether to recalculate column, gutter, and container widths again. Defaults to ",(0,s.jsx)(t.code,{children:"true"}),"."]}),"\n",(0,s.jsxs)(t.li,{children:[(0,s.jsx)(t.code,{children:"force"}),": By default, ",(0,s.jsx)(t.code,{children:"update"})," does nothing if the instance is disabled. Setting this to true forces the update to happen regardless."]}),"\n"]}),"\n",(0,s.jsx)(t.h2,{id:"layout",children:(0,s.jsx)(t.code,{children:"layout()"})}),"\n",(0,s.jsxs)(t.p,{children:["Use this instead of ",(0,s.jsx)(t.code,{children:"update()"})," if you don't need the columns and gutters updated. Maybe an image inside ",(0,s.jsx)(t.code,{children:"shuffle"})," loaded (and now has a height), which means calculations could be off."]}),"\n",(0,s.jsx)(t.h2,{id:"addnewitems",children:(0,s.jsx)(t.code,{children:"add(newItems)"})}),"\n",(0,s.jsxs)(t.p,{children:["New items have been appended to the shuffle container. ",(0,s.jsx)(t.code,{children:"newItems"})," is an array of elements."]}),"\n",(0,s.jsx)(t.h2,{id:"disable",children:(0,s.jsx)(t.code,{children:"disable()"})}),"\n",(0,s.jsx)(t.p,{children:"Disables Shuffle from updating dimensions and layout on resize."}),"\n",(0,s.jsx)(t.h2,{id:"enableisupdatelayout",children:(0,s.jsx)(t.code,{children:"enable(isUpdateLayout?)"})}),"\n",(0,s.jsxs)(t.p,{children:["Enables Shuffle again. If you pass ",(0,s.jsx)(t.code,{children:"false"})," as the first parameter, you can tell Shuffle to skip the layout recalculation."]}),"\n",(0,s.jsx)(t.h2,{id:"removeelements",children:(0,s.jsx)(t.code,{children:"remove(elements)"})}),"\n",(0,s.jsxs)(t.p,{children:["Remove one or more shuffle items. ",(0,s.jsx)(t.code,{children:"elements"})," is an array containing one or more elements."]}),"\n",(0,s.jsx)(t.h2,{id:"getitembyelementelement",children:(0,s.jsx)(t.code,{children:"getItemByElement(element)"})}),"\n",(0,s.jsxs)(t.p,{children:["Retrieve a ",(0,s.jsx)(t.code,{children:"ShuffleItem"})," by its element."]}),"\n",(0,s.jsx)(t.h2,{id:"destroy",children:(0,s.jsx)(t.code,{children:"destroy()"})}),"\n",(0,s.jsx)(t.p,{children:"Destroys Shuffle, removes events, styles, classes, and references."})]})}function h(e={}){const{wrapper:t}={...(0,o.R)(),...e.components};return t?(0,s.jsx)(t,{...e,children:(0,s.jsx)(a,{...e})}):a(e)}},1184:(e,t,n)=>{n.d(t,{R:()=>l,x:()=>d});var s=n(4041);const o={},i=s.createContext(o);function l(e){const t=s.useContext(i);return s.useMemo((function(){return"function"==typeof e?e(t):{...t,...e}}),[t,e])}function d(e){let t;return t=e.disableParentContext?"function"==typeof e.components?e.components(o):e.components||o:l(e.components),s.createElement(i.Provider,{value:t},e.children)}}}]);