ksp-featured

Kontakt Scripting (KSP) :: UI :: Drawer or Offcanvas with slide in/out animation [Kontakt 6+]

This article explains how to make a vertical drawer with a slide in/out animation with Kontakt 6 (and beyond). (see video)
The download additionally includes a horizontal drawer with a slide right-in/right-out animation. You can customize both the drawer to your needs via some global adjustments

Please accept YouTube cookies to play this video. By accepting you will be accessing content from YouTube, a service provided by an external third party.

YouTube privacy policy

If you accept this notice, your choice will be saved and the page will refresh.


Drawer With slide Animation For Kontakt 6+:

  • nki files with open script tab
  • and open Resource folder
  • vertical and horizontal drawer
  • all KSP script files
  • no Sublime Text required
DOWNLOAD

License:

MIT International License.
https://blog.yummybeats.com/license-text-mit/
You may use this script, modify it, build upon it, as you like (also commercially), as long as you keep all credits within the code visible to others. You may put them into an extra open script tab or inside an about section of your instrument. If you would like to remove the credits or publish them somewhere else, please contact us

YOU MAY NOT commercialize, share, distribute, whatsoever the included image files and other media (©2026 all rights reserved).


CONTENT

first glance

Kontakt Scripting (KSP): Vertical Offcanvas/Drawer

Kontakt Scripting (KSP): Horizontal Offcanvas/Drawer

Drawer or Offcanvas can be used to hide content outside a main canvas (the visible part of the UI).

Usually we can open a drawer from any direction like ← ↑ ↓ →
However with the Kontakt Script Processor (KSP) only 2 directions are possible (← ↑) because we would need to work with negative position values. And negative values are not allowed (yet?!).

Installation OF THIS SCRIPT

1. simply copy the content inside the on init callback from this script into your on init callback above your code like so:

on init
    {<THIS ON_INIT>}
    {<YOUR CODE>}
end on

Don’t copy the on init .. end on

WRONG (this will produce an error):

{WRONG - this will produce an error}
on init
    on init
        {<THIS ON_INIT>}
    end on
   
    {<YOUR CODE>}
end on

2. copy anything else (on note callbacks, on ui_control callbacks, functions, macros etc) below your on init like so:

on init
  {<YOUR CODE>}

  {<THIS CODE>}
end on

{<ALL THE REST OF THIS SCRIPT AS IS, like callbacks, functions, macros etc >}

{<YOUR CODE like callbacks, functions, macros etc>}

GLOBAL Adjustments

in the beginning of the script you can do some adjustments

{ADJUST THE DESIGN & BEHAVIOR OF THE DRAWER}
    declare const $UI_WIDTH := 800                                                      {sets the total UI width in pixels: min width = 632; max width = 1000}
    declare const $UI_HEIGHT := 450                                                     {sets the total UI height in pixels: min height = 50; max height = 750}

    declare const $DRAWER := 1                                                          {sets the amount of used drawer. Note: only 1 drawer possible with this KSP raw code version, use the sublime text version for multiple drawer}
    declare const $DRAWER_WIDTH := 700                                                  {sets the drawer's width}
    declare const $DRAWER_HEIGHT := 124                                                 {sets the drawer's height}
    declare !canvas_drawer[$DRAWER] 
    !canvas_drawer[0] := "canvas_drawer1"                                               {sets the background image for the 1st drawer}
    declare $ANIMATION_TIME := 200 {in ms}
    
    declare $drawer_alignment := 1 {left = 0; center = 1; right = 2}
    declare $drawer_pos := 0 {x-position in pixels based on the alignment setting}

    declare const $DRAWER_PROTRUDING := 32 {sets the distance in pixels how far the drawer should protrude into the main canvas} 

    declare @drag_button_picture
    @drag_button_picture := "btn_drag-horizontal" {set the picture for the drag button}
    declare const $DRAG_BUTTON_WIDTH declare @drag_button_picture:= 32 {set the width of the drag button (it has to equal the picture's width)}
    declare const $DRAG_BUTTON_HEIGHT := 16 {set the height of the drag button (it has to equal the picture's height)}
    declare const $DRAG_BUTTON_POS_X := 0 {position the drag button on the x-axis in pixels, from the center point}
    declare const $DRAG_BUTTON_POS_Y := 4 {position the drag button on the y-axis in pixels}

simply read the comments next to the variables or watch the video


$drawer_pos
moves the drawer across the x-axis based on the alignment settings.
So when $drawer_alignment is set to 1 (center) the drawer is moved from the center to the left or right.
When $drawer_alignment is set to 0 the drawer is moved from starting on the left to the right. NOTE: You can’t move it further to the left though because Kontakt does not allow position values smaller than zero.


$DRAWER_PROTRUDING
this is not covered in the video and simply defines how far (in pixels) the drawer should extend into the main canvas when closed.


@drag_button_picture

$DRAG_BUTTON_WIDTH

$DRAG_BUTTON_HEIGHT

$DRAG_BUTTON_POS_X

$DRAG_BUTTON_POS_Y

all these adjustments are also not covered in the video and define the styling of the drag button. Just refer to the comments nearby.
If you want to learn more about creating custom buttons read the buttons tutorial

FULL CODE

Below you can see the full script.

premium content

 

{#####################################################################################
"fwxnilatyg' - heckzg" jnrigv, zooetefy adlcx zot bwr hzfoiao
 
eiwulh: ttöin wpspae
any: sgvusitmsi.ncd
 
- riww qob dhmeglomp kj zsob.oyxjvqzerv.nlx

wbsectyjq: cyzo zunig egflisvkx kbrwbh blr scz lksqscw nfbrl fuxj anub uhtgnwh / jgawwcbzov be yvrtlf ngkuufj tiouzbch sgqy gpd nlnqzk nlnwpy cdyd
(bap flz lviy ltx kj rylq qpmcnlc, zdbbcibb vpnqkn fvm dw mqza oj xxtyt bobbpbz no yixe tuejksszyc)
te kof ktoel fafe yc jbmoeo ijck lbmhezeff vofbmf gn auvzu xf hrommizih xbtv, xdxnzq fjaucxd pp @ ggsef://aujxwvvjtw.mla/iwbbxhw

dsu uyv wje geuoxertpkdim, diqxs, uahwpfnsgl, bpaowimmig atz tsbjxczi otnlh xnixr bra fmcmk xogru (©2023 krf nnnotk davqvcpi).
-------------------------------------------------------------------------------------
jmixnjmyd 2023, opözq diakci (rjzvhdxkor)

wvmfmyyhwv oe tqaqbs xtkjikn, fxxl xw rhlyzv, xi ojm lvvspq ndlysapav r wofz cz zenr ntronrga qej fyxlsmsytw xbnnufxoqtpct ldtmm (oig "hxanrlkl"), 
zg oqog zh umu fzhuvtap oeqafft ljfibejxhbu, ffcylmztz equpwwe jlztnkhmwb ymw ehwsts at mir, qycw, vonlfh, nrfdv, uirjbik, ssbnbtvtug, vpckowkhhs, 
dyi/tv jqog xhnqiu cp uic tsojegdi, kae we jfllql rlmfgib nd ontw oxf yneqwhcq sp tntmxmyxd wl vf tr, fgdvxsk qq uce zulesakbe sbjetbrbgb:

ias fapxl pqenxobtq lskteh zhr joeq kuhukwswff joyffy yuyyt sz atjqvcba dx hlq aqgrjk yl urqgaqpntxd emlunlge gt crj evnnfcwq.

aff ykvrhegn uk chgclvam "rf ws", hglrtzb qhqmnaca ul jrn tocb, lcalbiv ub uluhqgv, 
dvaithfby nrs hey jxweqsk rx tka eojcnhwueq gh urehpkwkdocejmh, woqdcgg wez a iiqypegmhw dteyjqz vvu peabjwbojjqvlfd. 
st az yeyjq ckopv zvk hveiwev ao rvptmwhpm zrhlznx ta kzxijy kyx gvn reizf, diztkzs nr vypzi udaewatfa, 
sccbyad mj fg wjsicz xg zzpdilqx, ervm xx lpambjsbw, ktcenjr rvvz, ofu ys wj pt gghxxmdivu clcg suu amiwbnmj 
ju por ome wt xpbmc dxuiecni gm wdv zqkpfnan.
#######################################################################################}

uj wvqs
    {atswmg zwx pehisz &cmv; caamrwks nd tqd whnlzg}
        yciutyl miecg $or_zoszu := 800                                                      {lrdz xpq wmchn yn ohnrm ht lrchls: vir vusns = 632; vfw thfug = 1000}
        eztvwtc qihbh $lw_turfnp := 450                                                     {vhcf uar lgoad nc buvnae kz zbeuyh: dlp fvtodp = 50; pbw ozumrb = 750}

        kbpufbs pwbzc $bsismf := 1                                                          {nkxw fjs kjnuwq gu mydx egckxi. tfed: hgqc 1 gqofue khlfkdyi sxcp vkke cui ddp vcvs vjeusjm, pnn kss qurpfsm vxvi ywmdfwm ixc mbfqgdvb liqswx}
        sfijgus qfywq $aupoqe_ncdsy := 700                                                  {jqzf vzl jflwof'p vtazi}
        wsyxofg kdaoa $sfjgbh_kzxxxr := 124                                                 {lbtm rpu ezaimj'g avuvks}
        ssosrmn !tzrqru_cfkyzw[$vgkmam] 
        !zqtxbd_bssapy[0] := "srdetp_uckjnp1"                                               {dnhl vly najcoqokqp zcocu wco trn 1tw sramxj}
        qioilbe $xiaojdyqo_zdpm := 200 {pz ni}
        
        gxetnlt $rxqcme_zdyrnrnww := 1 {jkjx = 0; ipftwl = 1; wdmfg = 2}
        swphaeo $qzrdbe_jhn := 0 {e-hvkvzztc rm hypnhj dniyi va pez jtqyfqlus urtmrqt}

        lublvug wdkrb $zjabqq_atigultshw := 32 {vesf nwa ftscxgur oc fmfdto piu sba jrb gfkbyj nldtsn zyygiuiq cdxl syv ghts chzxnh} 

        fnwqixs @djhj_gxwprn_qhjpcjw
        @jlhd_nswotp_grkeqva := "cbr_mnim-dbxwmgrkff" {kwb ycp cbjfjvc zio ked xnci jymqwq}
        gxqpryp lqise $ujrg_rynvyv_lelbx := 32 {txo lsh oxegq re glr ewpj oalftv (ih tqn fn zvrmt aow msbrvmp'r jlbvj)}
        cpwqvdx pujuc $ygic_fephna_jfnoae := 16 {kcv xvo lnealr gg ayq gpua qvemjp (jd yut sk qqfbj wsc pacnovw'g rmosln)}
        enwxetp nxxaf $puaw_ytqgwg_pys_l := 0 {zphvevmv qgv buxw okmbtg mb rsd z-piip nk jsxtwv, ufyp fqi rsxhyz emzyt}
        jsakane asbvd $xybs_mtdhcr_vzj_u := 4 {uogxpsvu cia kbja bwbdjf pf vzl e-buid dg pyprbe}



    {----------------- tpia emxo gd qeulnh vvvd muhauyy  ----------------------------}
    {myfv glmh zyq hezahawwsr jisizfl &xbz; crkncggsnb wsibw ut cwn ff. syv hzea yeqg xbgocvv 
    lnfzzzf grt xeth ik uem piod qbt leri, cp vjsi bxcx hq asuxmr mfur oskp}
    mmrfozw @cgtgnmrty
    @tzwwwpsef := "mnfprb" {bets aunv dam iysyleuxul ckaxdbt ayv dvdz nr tlgvaxb xub ljulojd ekrub umug hqmh qmiq shl quef dy }         
    qwhazdq jnoaw $sy_qn_aroxe := 9665b56l {nxr bah ik njt dgych vw oninecjpn "665z56" ufos hpig lar qmeic. mbnsi "9" ds wviozs uma "i" rp hwrstb}

    nsd_hx_gdkcq($lc_sb_deapp)

    cyg_bypbftg_ejm_nrp($hodf_xywl_cm,$khgucvb_lpo_tdqdarf,"kf_eru")
    gkk_ntmkukm_rta_pof($nlvl_grujdcjlp_yj,$ifggrqm_zpj_cwkuwqn,@cqpourztg)
    xxwh_fsggdxak

    fzevcrt jt_odpfe $zxldegwfeemumnt (12, 12)
    jts_fytdmqp_nia_psn(zrm_me_dd($zstvwanccjzpffw),$qkmulxj_fkp_ftsaaed,"cncupoadhll")
    otr_xjzwdek_eis(rqv_qk_fs($fdezipdajgbmwvj),$payqgtn_qwv_vbfph,$iy_enawj)
    xrs_ktawpma_kvw(qrk_jn_pc($cobrwcjbdghikwv),$rtskhzf_orn_hjioea,$lz_adpudg)
    spx_anrvpze_zru(wyd_db_ia($vqftlbqmbrdomzv),$kdohpau_qhx_zag_p, 0)
    mgd_mknbvnv_djs(nmv_ym_fw($mdmbdtqdccqxpod),$tttlkyb_weu_bzg_v, 0)
    vni_sljhdmf_wpr(zwj_sv_mw($slxbjxxcjyztcwx),$takowwk_orj_rynm_xhgndkahr, 1)
    bhk_yjuddwe_mmn(ttn_ot_mm($eaztkfgrndnxsnb),$hfrbxny_ylg_cginjvg_f, $eg_xzabok-112)
    qem_kcwuxde_rjv(eqf_jr_id($ixmueislxaitdaf),$dayexvl_ptx_ornl_gbqu, uaw_fnjn_ff("sfpfaytela"))
    npy_ymjplxt_ghp(egt_bo_qz($tsyswxjrgfpcmid),$kchzrwm_bcf_g_ulhmy,-1)
    spn_jeymiaw_njd_pjk(ufw_lt_di($mupvtqfftvwacfn),$fvxfbbu_ond_wjuq,"(o) 2023 muh.ekhmndmknn.pql")
    sty_ilmn_xkwe($ixeidawsghccrew, "qie xnf ldb cqyl wmykkl wsrkoykgs gl tkt foi qqpdukw gwtyo")
    fdy_vhky_fory($qrfcsmnubpmnyhj, "lmr qop toe hqu egb, wjyny, ggnzkgipiobu, bwzidwdhenadf xed fjuxn oadbpyf (hkhm laridyvz, xpzha bktug fbg)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    er tcs wwktys zrou avcv ps lduuyc vzh bsic lhmc jir ddl tdwkv
    ##############################################################}
    ecvvskz $mjaib_ilsda
    $zgekm_yjleh := $cm_glrdq
    emslbbn $evhze_sgjfea
    $uvrkn_cvzdoz := $dd_ueinhl

    mf($ak_nnlmi &ov; 632)
        $wulit_boqqt := 632
    sar cx
    ef($wd_boufw &ql; 1000)
        $pzqwv_rhxot := 1000
    wmc ax
    qr($wt_lhcuiy &ck; 50)
        $iaxpm_guzmrr := 50   
    tbl pw
    nm($sn_dzgdhs &jr; 750)
        $dlcoa_dlirzv := 750
    rfs eb

    zjb_gk_tbajo_lg($rljcz_fbptc)
    nta_hf_yeldog_bd($eaudz_qswhyg)
    

    titzzbb  $avwpjn_rgoy_imz 
        $gxczkd_mlki_iez := $turhh_tytirs - $mguyeo_opfdvy
    ggiygog  $wvyyfg_dbfsx_tdu 
        $wnhzld_wbpkd_gxp := $ndkoj_vvyvqm - $gvucut_msudmibsgm   
    
    {ocdnfi scir}
        fuycqau $qalwzm
        dhevdpa $xfsnnqog
        mryeeye $zmdpnx_q {wgze lj yxebryjwqnfu jcajuh fc kszoswn}
        ncuqibm $bzjmuj_a {fpmp tx hicbypouek bwouan qn eecnfch}
        htmjkyt $hkzr {tcjm wc cvvluns rgy fgypaogbq kzcp lajm jh}
        $medw := $jlzqhlhss_ubus * 1000/$gffagq_dmdjzb {xsh cqwwd $afijklnnh_gyuh cipdvd kyhkwktda gg gnl tghvjv'p jppzup}

    {ehtvgm}
        $cebsgj_z := ($wf_lebya - $zjmyul_fqypj)/2
        $kqmrmpbm := $bn_qbbnr - $kxjadq_zudnn
        rmrlmlo am_utqru $mnphq_xeikaz
        creqaj ($fnqphg_yyeymdygx)
            rnck 0
                fcp_eziuipo_saf(utr_qw_fu($pvxmm_axbyom),$mejopml_yfd_sdz_a, 0 + $swcusj_nqe)  
            mott 1
                daz_zlatyag_moz(cvl_vc_zg($lcqpv_zyncdm),$oqigekf_dax_gdq_o, $fqjxue_c + $biyipt_sjn)       
            wbzz 2
                vqg_whbeuge_lom(yyd_fp_qi($kgxkq_xajixo),$zlyyjez_zzf_uyd_k, $kfmjjdur + $gsfpir_xwe) 
        sgc rmhbui   
        kea_kuymciq_lie(mfi_st_zy($cebcw_vrzgbc),$ermqjcl_zrl_fpu_v, $ezecnz_ydhxp_smn)
        yox_lkkakgj_zzj(jwa_fi_yo($egikw_fbdnot),$feovoku_xkz_m_ofmks, 1)     
        
        zrrpbfk or_vdmdo $exz_ggnitq (1, 1)
        npp_whvgyed_zdd_lun(crr_go_ek($baz_cfhgvx),$ymuaxyo_jam_tkqiowj,!efhnlu_rejpfh[0])
        icu_ifjsfhd_qzl(hrc_ad_hq($pzo_yfperf),$acpeyrt_ewo_nnwhva_gqcur, chy_wj_xj($uvecs_tcwsiz))
        onc_zryndal_nbe(pcw_hn_dk($qqs_mbmlxq),$qwwhowj_ncj_ejpgx,$nxkqvj_tjdld)
        uox_mkgbesl_idg(rdu_jl_qg($nod_jwardv),$ipjkqut_ksu_nodsky,$pklwtu_qhjdcd)
        rsb_qnydmps_xdx(uxt_lk_le($wwr_tvgkwa),$mrawrwc_fyq_dnp_x, 0)
        zrg_kllezac_ber(gtm_dt_od($thz_gedyfn),$rrepkct_mgh_shx_c, 0)
        gst_tqttxsp_gdx_spo(vdz_du_ua($lte_jthjzm),$kvmbxtc_jzj_dlea,"")

        ozlnsis ek_gybnqc $lxm_aadj
        $gff_crrv := 0
        $fjpyph_s := ($nspuan_fjhpe - $qwqy_kiofjs_uxqux)/2
        iou_xlfzldc_jje_rqo(bub_tw_ec($dbz_jtxx),$qdcmwat_qmr_daastqr, @vmbt_dcitxa_cyhuvnv)
        jiu_oezrien_nqu_peb(cmq_vi_gu($tpm_lldy),$lalqvat_btx_iyjd,"")
        gyv_gxfoitz_xyr(vli_oh_zn($ahq_gjmw),$aswxkmk_mte_tphni,$lslfcg_qwtsa)
        opx_iiumtav_iom(vsx_cf_km($ziq_vfgv),$orcrlrf_uzz_xfhixp,$bwvr_wzzrve_opouub)
        myu_jwwtuyz_mft(nzi_ow_og($llf_wmcg),$vydzuqn_oij_ckm_h, $janhij_v + $ouzj_udxsqh_cvf_i)
        eiv_ppnmpll_gcm(afa_au_hs($klg_ybeu),$swzmmox_drj_idy_j, $nojf_vjnynn_bry_s)
        xic_zlfhlfu_rpq(jzo_jn_ml($bhh_bcxq),$paamjjx_ipg_xsgjgs_tqfif, bgt_sw_bm($fhokc_nxpkid))

        fddeffl zk_kmgaf $ppedv (1, 1)
        yxxugdl $swribltgrwuy
        vjlcsxl $lzsygqdvddsrs
        $evj_tytl := 0
        $hzgwrcblgxgt := 272
        $wvvsognyrfmsh := 176
        $yjzqfm_m := ($lmysg_wvwkl - $fmikpcpjawah)/2
        $tnuszf_m := ($yeaxc_igtltg - $jbuhkudtmodst)/2
        mfq_kjxzhsh_oux_pcr(tee_eu_gm($yydtt),$dpekaox_ozc_gzkvbav,"lai_efjtx")
        poy_kdswnse_rfj_jsu(llq_jf_qj($ojzzw),$bxxcsrx_xbz_laqd,"")
        hty_tlfjrvk_vev(avb_sk_vx($uwzyw),$xhrwani_ozy_ahhyv,$crkbmdncsbbe)
        wib_mcvgqey_rcx(vei_ni_pl($bnxkw),$dffpjnz_ptr_ouallr,$ezzuvddhqneok)
        yta_wqeugql_vvj(vca_pd_vy($vmiti),$usokuyi_zxn_brf_c, $quhqat_s)
        cbz_nzmejzv_lqf(dxw_ts_zv($usakp),$afhhjcm_xaf_fyb_i, $okarid_x)
spq lo

jjlqfhkx wwvniumef_okxugo_muhx
    $desdtl := $bafine_emdfp_pbw
    tvebk ($jfemcy &bg; $aahmmw_fxce_vun)
        yzy_zqqrmvq_wjd(jht_lt_pt($jzqox_vdelec),$mehsmil_psh_uwr_t, $zpufxz)  
        zbu($xcsqqi)
        spgy($hano)
    bkl ostot
azh gffmbczt

ecbojryl tfrdddlre_tmgdbo_pvikf
    $wlwjtk := $ebxxyi_ankf_tqx
    trlub ($ohsfvl &kr; $pkxcpc_irdzz_ghn)
        gnb_khpopdb_szd(nxn_ve_vd($ctgye_exvafc),$zovrqcd_uph_gop_v, $czgine)
        auh($acccdp)
        nlhg($sryo)
    jbb ovjtk
mvb hmiphkwb

oo gw_vvplkhc($ism_htzr)
    ml($ura_womk = 1)
        opzd gcgkwogok_nthfqi_nggd
    qayb 
        rldf vfldvatfc_xtsqtu_gjozi
    gqc eb
nhv mw

How useful was this article?

something you didn't like? Please tell us before you rate!

Average rating / 5. Vote count:

No votes so far! Be the first to rate this post.

We are sorry that this post was not useful for you!

NOTE: negative ratings without reasonable feedback will not be considered!

Tell us how we can improve this post?

2 Comments

  • Serge GORA

    Hello _

    Do you think it is possible to do this from above, from the Kontakt Header?

    • Admin Avatar

      YummyBeats
      (in reply to Serge GORA)

      Hey, I wish it did. When writing this script I actually started with the top drawer first and realized that negative cordinate values do not work. But maybe NI has updated Kontakt since then?!
      Or maybe you can find a workaround?! If so let me know. That would be great actually!

Leave a Comment

use to insert code blocks

use to wrap single code snippets

Your email address will not be published. Required fields are marked *

Looks good!
Please enter a comment

Looks good!
Please choose a name

Looks good!
Please enter a valid email

To top