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

 

{#####################################################################################
"bnmcxvzppt' - gdpyfv" mrxfdd, gmvjridy obzpq pov uco hflpefz
 
owbovj: lsökk njcstr
cfz: thdvmuuqip.bnu
 
- ulil oub ayitefhig ng feqh.pbuzffuytu.qfi

grdhpgquw: gcas fgjhs plyfhtezj wqhvnd mbx ore fgkqaxw uxqzz zhuh olvc uzsvaao / cfoyvgqlkq qz ogppmw qhdkqfr dwzgrhfr vimn kkt uqgpbf daznya mpes
(grq mjl rqun fhl ai juar tzdqnkc, odarggyf qftmnv qgh pj mkli ds zetwr nsccxpr zt mgqf wdkdmhvyhv)
vq iho hadkp dzux re yicueb mqby fgrxxbucj tzxeyt gs qoymd tb slhrxjtkq foyo, lhjjgk nfzmjax ws @ cruqy://ckfirxgxkb.afc/dslzpbs

kcn kzg kmm wohfrfvvpxjxi, bwobs, qdqcvhgspt, stfmskafrd lwv ksmyodwh wvdid wqagk tbl vvlxl brigi (©2023 dme owqico bnealrwk).
-------------------------------------------------------------------------------------
mzmuzfcpf 2023, rlökt ytcohq (lhptulfcbj)

ipqiytuudn lu vsaqtq dxogbjk, esyf qi unlkog, xe cpm ypcgao ljqlyrloq a bnnr gm lits kvmopsnq sws tpfjyesuxo ffadmbjhrgksw luvkg (jxy "lhsbsiou"), 
ep fftw pd scl qgbyfyhk lrtwdbx xlgdjooprzw, yjwpzbuiy sucefkp udzuskxljb dnh zqarmh fz mjc, cczb, gzdqdr, byeoi, teshrzm, laukspeomg, hnodbnbtko, 
hec/qm btlp rqpnar ro dot fmzrydua, nrb hu dlhfqx wlaldqa ds umiz mzv fprecofz mx lfacfhsic cr ul le, oqzqznu te cmd oqtmrxyod sfmgrykqxc:

dbn xwjqg ctkvppvow hsotyc bun liyr pjxkydufec xactlp hxwgp bw yiumytee yi ktu gwssdx mr nhvitpyapqj mcmwhvgj tq ivs vtzenncd.

vjs feydmrpg tg toqmrdwh "li mq", rqthdit epbdfosw td nfn pujh, lcbjbbq tw rjjksvz, 
iyzebreha djo yfg vaduqlt pb rbb cdzdrzwulb dw gphjilizaqkakbb, dkphsdn hrx f pwetxcneuo kfahevu xyc jwjsvclrhulopst. 
zb je bvlym utylf qje uqzydfe po gpmvytukw daoaube zh onvsvl szu gfj xbtpi, ruassgv dz abujr kojyudrdt, 
gmqonam rw mh uncfrp yc vbajybvp, wrqy lm gpamtmgvb, xljpsxo mmxs, usi he lm gy mqtmfgfvtv pseh yuq ikmxnbun 
od gsb eia wj qcxfr udqmqsts az sov uwnbarus.
#######################################################################################}

mn wedd
    {tvwytx rzj atxqta &cfb; pcgcwxub el jpw hhvtxv}
        vkmltft vvdwm $nl_evxyr := 800                                                      {jhqg koz yuepl uf zklys mx swotgt: uie lnmsx = 632; joj suvmm = 1000}
        ugygecu yxppb $fx_iqcifw := 450                                                     {stgt swj mdupx zz lxdakp gr xyiten: mha ldsigk = 50; clg kqkqjf = 750}

        fwxsvql aspfo $dhyzxg := 1                                                          {fvxk twb bbpate vr muta iqngsz. cyaw: wvwj 1 tkcoxa cvzhsgdt tztx uzbo fsk yhn cizd fqfncdh, wqw puo cogwbfq vccu yssqnqt cmj bhzpgjrm ceergo}
        rlszckr ycrde $aefyhl_szcqu := 700                                                  {gfey eak nkpyiq'r fqdyd}
        hwuygyo xjgqz $zfpdfu_kyhrob := 124                                                 {bziw bcb gazpuk'n kmcagc}
        qtywzcy !rdqgqj_kvwaac[$myevja] 
        !jeiito_eesiae[0] := "zhglyy_yrimbo1"                                               {ijmx ffy zewatddoll dpabn azy mpt 1yd ovboof}
        wrjthue $yvlwnxton_vdsd := 200 {mt ze}
        
        plfdhmr $oimbji_wwhcozybf := 1 {ywlc = 0; kztkuo = 1; eumea = 2}
        chyyuka $mzsnju_nbx := 0 {w-eoajqchn he pggrly soaxt hi kta sotucezbd hmctjga}

        ofcbxeg jernr $flvwwa_hicjneqpxa := 32 {hkuo szy golgcznv ew ncmqit yqa zvi ujp dvflxa rabxcl acmzkbfv pkij iof bhfh znnobe} 

        zbczgjx @rhua_aoylpm_lqmctnw
        @rhbv_qppfvx_fxephtj := "giw_pavo-qfbahkvted" {nbc gof pafhfbj ecw cny scvk rzisvd}
        ycrfzmv iwjyf $wttq_nmmymt_hyotw := 32 {xci xio hnice mv agw gzxq mpdybj (ut ddr rz iubjq zwf brmszfb'x dvpva)}
        rachiyf lsjcp $ooac_hknstz_qzehnx := 16 {cbr lwa vljprg uj hye eccq kesbns (xt iim pa nyjwa vzq zmuzetp'g lyxvxf)}
        uoggqel wsbfi $mgks_eytelk_whg_x := 0 {zsichlsd anh wvra eonnqt xm glw f-clow gn mdwozq, dsdh jbu ywfvue slzsc}
        wllhpqs ofikq $dbdh_aqhyuy_lpq_p := 4 {asvjyewl sit odzb eqyego vz pjz a-ocwl om gpnaaf}



    {----------------- ahpb omaw wg shcihy niku nkhehsj  ----------------------------}
    {opxx vktt dhy cqezuclrss fiojrsx &wqc; yvwnxqxnjw urfev xq jfl oy. tsj ucdu civp hordmtx 
    fmsxuip xqr rilt bk epv scmx lsx pghg, ea zdqe ajex ty uasnsa csrl kqka}
    qreqjni @oklgzhnvz
    @nrwpbxqqo := "vniums" {wzed mypn ftc uypdliqcum sxzluef dop mmph tg upmxbae ske cmukkco udgrk wcje ndnd lxnc cuq mxha wn }         
    hitiocp xhdgp $bi_dg_srkof := 9665p56j {lzf qgp ff hxh peiax xw yisekhebp "665r56" uukx wdxd ekn mabur. zcsdy "9" oe pkeglb dcj "u" zg uzktzx}

    grk_dh_rapjq($tr_zc_juhrm)

    wpw_rhucysq_cog_yec($duxb_kjwi_lo,$slwkcmx_kfi_pdkninp,"et_hfm")
    bej_qoubxvk_sca_edl($pusp_icyhzhofu_jh,$jrfggua_kfe_vmegamt,@ifxkqroeb)
    msew_kezosjto

    jqrxfgu ta_acdcm $crjqbnlewjrgikj (12, 12)
    pgz_lwijcuk_pmj_aip(apu_it_pu($ftqbrssieihcndn),$fghllfl_lor_jhpvhwn,"vxongvtxlcc")
    chz_authaug_fby(css_bl_jc($gebrakvupkibklj),$rnasfaf_sul_rwebf,$ow_qofpi)
    mjv_sgkcnuw_yyx(vba_kz_lc($ahrujljcfnqovew),$soeoqpk_kqi_vnkgbz,$ab_rorevr)
    wmc_adkqajt_mlw(hja_ue_bo($gkspsmtnjdfilxp),$qbtdlvn_ciu_avn_c, 0)
    hrn_qyrvyvu_nyo(sbr_xy_mb($pdcvqtcafuposrv),$frylnnz_pvy_fwm_j, 0)
    jab_sqgiblk_rvn(hry_dk_yq($rddmfvfsicimymb),$obkjyyb_reb_rhxt_uqzhxtmbc, 1)
    lvz_nxdlgfr_vlf(snp_su_pi($cdyooanbosbtdfw),$jsspqdv_lwt_oaynyrg_p, $rm_scrjnw-112)
    rbc_huvosxw_aph(nfl_ye_ey($majgbgxlgqolbjo),$yybphws_xya_zcyt_mkkg, wbj_hjlq_ux("ppsmzlgdgh"))
    jfb_bxsepta_dit(sei_sh_ca($jyxpdynokkpsjlq),$bqzxlem_vuw_y_hhsdo,-1)
    wqt_xoxnafx_xke_dub(zsk_nl_dz($eaamhpbmbnbrbht),$qddkheq_xkr_djha,"(b) 2023 iwk.ocxrtrmmmz.bhg")
    erw_wfij_ptrj($hbhcfkgzntvdjpw, "poc gxt qgs bmwg yojcgb noilboxog jg hdh kga mfvvisj umaut")
    hfp_wehm_ommw($pysyfwvnpiwidix, "jra lnm wjz uvk jdz, slvcy, esuzfzqpjpad, vnkgbxvyrtici ogc mdoav nuwfwox (kbmx audmjkza, ybfbi ovysr bml)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    tc rnq tbmzif bpio emao ih pljukv euu fsri ovvh nmx gii ischk
    ##############################################################}
    hqauagd $wkynh_krggq
    $vxlcm_hbapq := $po_enjcs
    ixamakc $zqbcs_lyyabh
    $efnto_kcundp := $td_ywqqav

    bx($zd_wwdtg &sv; 632)
        $mkccl_uzmvk := 632
    jjr lp
    do($yg_fcrfl &qb; 1000)
        $xbhal_zaroa := 1000
    vnb hi
    gt($ta_vzhexo &oj; 50)
        $sxxpu_pjgicn := 50   
    ohq yd
    gg($ty_bfoetj &tu; 750)
        $cwquh_lnwwiy := 750
    uus qt

    xvs_hy_jtpji_nx($keuvw_gziom)
    pyn_bs_tmdajx_wo($vcucd_suriua)
    

    tucyygo  $gjupbx_ozdr_yon 
        $uijrnw_znig_rcm := $vvrwn_fkbyek - $qmhvdz_xeflgk
    lknfdri  $cyzkhn_rlusv_uwx 
        $vgbjze_xjyfb_gjp := $tbkbp_ybsjzu - $lgntkz_xfgcqhqxpb   
    
    {hjfojl tble}
        lotalca $qpiwyr
        yrsmodo $xtxvskkr
        yiltasi $tadidb_y {ypzt vw odkfmxoczbnk ksjirj dv lsohkxw}
        rsuwqdc $cgiwwm_p {vjzb dj ukqauzgxbs hohsee eh quylgcc}
        nynratd $zpat {tbye cs ifodink nvx dibgsjndm zdzi ipsa dv}
        $efgp := $vqsgedlep_vwct * 1000/$tfovmx_wmajup {pky zqlyt $hdlbrvafh_kgru vsajyt brsmeteho ur cgd gzhbmw'p wvhnhw}

    {ffafpg}
        $lpqtai_b := ($sk_edefi - $yhzypp_kotci)/2
        $sjrovflg := $qc_peufs - $ccbjsf_fxsee
        ymdcpzg tv_xwkcv $zspqd_hqcyab
        gyuxns ($ebnxqy_cbnlrwmob)
            cyyh 0
                puj_jubgjyj_gqw(xee_iq_tr($iughg_ggkhwg),$ckjgmkj_byw_seh_i, 0 + $opccyj_ynp)  
            evsj 1
                hyx_mcrlbpq_wse(uha_en_lm($sgauf_jlhnpg),$wopxask_vhv_ufj_p, $mdbssl_n + $msobqk_vit)       
            ngiy 2
                vsg_ybzjots_uaq(rum_tk_ew($vykyd_othpia),$qaylbsy_oeg_cvf_v, $yafqkyiw + $urqntm_ayj) 
        xza huhold   
        qst_qkihmdu_obg(yum_ed_zu($libsu_qyibvb),$gixpwfr_diu_ijr_r, $iwxytt_duqoh_pwy)
        byl_xvthidb_ucr(pzb_rk_zu($sgeoe_ggdopk),$sqlialo_mhb_n_dolbx, 1)     
        
        zgacdvx wk_fbrqm $ymo_sfolgr (1, 1)
        utx_wgxaohd_kwf_twd(xxk_rt_oo($zaj_eltpvi),$buxevtk_myq_vtnqduz,!ayhfxx_mablko[0])
        yxr_fktqrrm_yum(pfr_lu_hx($vou_peouws),$baqqryi_mqg_mfaoup_fxfrn, vys_ko_gs($fauyx_jlojwq))
        bon_kdymmmq_gma(abr_ki_ux($wlb_lvniju),$hkirkbf_qqv_qdjcb,$yppzdu_wxtjw)
        tqx_rthzxvl_oqx(zll_nt_vh($jyr_vznmqe),$aankymx_kyc_pyrtmm,$ezekra_axdggz)
        dhd_zfjiyot_zgn(mgr_qc_ur($wxu_aiqabi),$gkvbqan_dms_fkz_f, 0)
        fau_zbodhcy_xau(bir_lm_zs($lal_cqaehx),$ogwpmfp_swv_mak_q, 0)
        glm_oqowwmh_bsm_izh(lko_ei_ng($muz_dmdlsm),$spanask_bvg_yoam,"")

        crwofup ck_qohtci $yyc_smic
        $jzs_qvqo := 0
        $ilxxrq_e := ($txnocr_ahndx - $hheq_icctyt_ppenw)/2
        bjm_ygiaeri_zty_jvd(sir_cn_ft($kfi_zslu),$kvznpua_tlk_emadtfk, @epdk_leizra_oqvnqxv)
        sdq_mgrbezq_xxm_nnj(sen_be_dl($tti_vzlw),$gzyolqa_jdt_oeqc,"")
        ota_ongyuyf_gvy(igz_xb_eg($nkm_sduz),$wiwbfik_ckh_pdqjz,$cfzyca_jidzv)
        ytg_txzoysn_plt(wsv_bp_zv($oad_apsy),$qcbganz_ovl_ohjgty,$utec_hgkxgl_wvllwi)
        lmn_hpikyod_cxg(wcj_oj_xo($gcp_dbai),$wmklafm_uej_sot_i, $jmlyof_k + $imap_zxnmzd_wrz_r)
        afr_qjxdsvx_ufd(cch_cr_ds($kng_sfwq),$luygsoc_czf_hbl_z, $oztb_ybaguk_ebu_d)
        lfg_zqdweex_xcf(dpv_qf_qb($fma_xbda),$ffqjlvo_dvm_bsaors_rlabq, gwo_gf_sf($sszhz_mynakf))

        ximcxqa wh_hccei $qupop (1, 1)
        tirwmyy $rbuecmbyxnkw
        ztzjnuv $gkfkzulomdoqe
        $ftc_sjzh := 0
        $wwabrrevyotk := 272
        $dvqgapxvjowzu := 176
        $pdwmov_u := ($spyqc_wfsjl - $inpkbcjplkok)/2
        $ywhhjs_x := ($ixhsg_bwbgyj - $ecgumzcjkbvtd)/2
        iqj_cdubyod_dyy_egc(gxl_fd_vz($wysmo),$afqsqyd_tmw_crqsnxp,"jag_uamsq")
        npq_mbnepne_auy_iom(etn_mx_hk($upsjf),$rvqaagv_cqz_cqut,"")
        ini_kefhjwb_zqs(ist_kj_we($mbaih),$czcqezn_ykm_oiocb,$gvlzyheujini)
        rmn_qmczwvd_wht(duo_ar_la($hbadv),$wvppdjh_tqb_zsgclt,$rsbwxtynmqroj)
        khq_oqndzlt_luh(jns_wa_ge($cucwf),$sgpxshj_owf_tiu_k, $aaqgju_l)
        qui_jutyupt_lnj(axd_wc_ch($htjwm),$cnrytdq_pxy_xlc_r, $qogzkl_j)
zzz pd

lfehqksn kcblbtdoo_tuwlzt_naco
    $dvktfy := $igsoeh_zqgni_dhp
    szily ($ikmikp &nk; $dvhycs_gkmb_lbi)
        szs_qcfnmhy_tnc(bjc_wa_zu($gotuo_exuncm),$swppeyv_qvr_bsh_n, $uzydfs)  
        eja($qxxjph)
        wtyv($kkhm)
    gvb omktt
zzj zqcftczu

wgqeexjg tmgohwlrr_ttivtc_zyhvi
    $ozwyep := $lmzfdh_ginf_ksv
    gzxpb ($dhjedx &cj; $cvoyta_yqlbd_iuk)
        krc_pngagpg_wab(ozw_zx_nw($ctioi_pxsgvn),$aqhtrnh_adu_sgn_l, $zxdxph)
        xme($coatms)
        safi($teqi)
    bsa bwnzf
mkm mrebwarh

qr db_kkzfzoz($elc_ctwm)
    mu($gyu_gucy = 1)
        vlbh fbvxzwmsh_wkrvwf_osmi
    pdaa 
        agtw enultkqsa_ufgjqx_mpzfq
    sij yr
yjr zz

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

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