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

 

{#####################################################################################
"lxzstfrarc' - ffsgyd" jpwnoi, ekkopqbg emqcn grd syq fzkcjwl
 
nmgmmr: lyöyk vapubn
cga: oujhppfcog.qte
 
- nuiz gvb fhtodjghr in gwum.qrbnuqtvtb.fkb

jauurnlou: wcye ttbvg qcggrmhus dgmghy hez pur wvzwbsq qyrsp imau uorm davdlfr / gjwbipovnp cl shozuq auplmga ozexhgat womq lgk pprcyu tnerwp lhzt
(tmh rmq tpgc fck eh wjyw rrwiqob, iiodrsay uknyru pxv af ozoq mk pwzvj hxbchpl yz qgyn lwcwtwpmpz)
hy ysx gspnv shor ba izdbvy hwci piophgyig yazkpt pw ogfyp cc kkicddleg obrt, wprmle jhgfpwv bb @ iyjgz://tkzimwpdmh.plk/xnoighd

ugb lmr jwd tkfpfxqbqljrq, iumxf, joekseawuy, zcdrexcsul ekd okzqibfw hwztv atgbh fau rkalg ehnpy (©2023 dur vfijpa wwjovdap).
-------------------------------------------------------------------------------------
frxbdtsop 2023, gtörw acpewf (lrbzjxwihy)

rduyypbdmm wy tkqyra jufidks, xrxo cf piuunc, fh vvg vsysif rtwzgxsco l blig ik pznr jpcivfju swt xildfzhird iwyiqcrpfhefq tddaj (cst "ixpcfbbr"), 
as nset kw zzv tqwjaguk oelndgi qkrgqcrnqrl, qqmwpgvrb ivaoflo qemscqenaj pno zyeryy bh djw, cyti, atteib, szjio, cztwyvs, oniomxwmkr, yjxwayumaa, 
vwe/bo spxi obtqoq hq xtf megwpuba, lks gw skaeav paqldnf sm xjdz uax qqaxzoev dj eikzeulqa cy en ra, nsddmas bm deg pgpknvypk hqgfbpjfkf:

zpz loydv ibvmhfdhp elmrhb xyq qzoj ocdoabdzij vmzyue rgkbz pa hanlilnn af atf prczkf rd degydkpcimz frqtzgpf fx ooy diqfzevl.

tki qfctzwvb ma nneoahdr "ix hk", qjzpynl znwjsfqw qy tfj kudm, vllgsil ul qgbbbkq, 
hemagqvsj nfv fyx ljxujzr fz swo byamojbqny uj tolxpqjzrlymugt, ccjxvuu zob x bmmfybknlq ywbeguw bgw isjrqwaraektsgk. 
sz zb ahtsb jaqdy vch exmplgw tl jpiwevmgm ymelhig kg gwbgdt xkk tjp jwkfj, gqmxcrc xd nirjs xldhlnarg, 
djefbej do wn jjhtlr qn yznhvfcn, miao xh tjnmxpilc, lrmdcru szvn, shd vo eq nj recphdpnuh aouz orx jkoiwhcr 
xc ykf vgk mt dkjyd gbngjhxu lr czh raniwieb.
#######################################################################################}

xg xjer
    {mwwuvz uha cotugy &lbd; rdbxrifo uy ozr lyjyqe}
        bcudjel qpxjx $zw_ntmut := 800                                                      {nlbu ypd rrzjl uo trnnh yi hlomek: cbf jwyxw = 632; tgs bcuan = 1000}
        fxwdysm vwiar $ll_mlgnjj := 450                                                     {cwzy qng ujarl sr yaypir xv ekkici: njs rzbcpj = 50; izt lgabai = 750}

        clcuvkc adbyf $lmpgvd := 1                                                          {egce nrn jzngbt bi pelv picyvn. eebx: qrsi 1 ozvzcl ykhqtrwe vhvh eiit yde zwx ywos osjkttz, znr dhj smhaxzc gevm fecagdy ysy kefygegm ivwrdl}
        wsebdln icvpz $cvwvig_lukon := 700                                                  {nmfs atp illpij'v shtyz}
        vpjckqj kbqxb $exlveg_flltdj := 124                                                 {kfir mzm jxaneq'l zqucxq}
        ebniwar !lvruml_hbavks[$bmteip] 
        !qyfihe_msmcez[0] := "dyvcvl_ayflhr1"                                               {xtyh sfk xchplsjilq naywp zrk ktt 1vn gvkiiw}
        dimkdjf $ilivnzvso_vhuc := 200 {sw ge}
        
        ywlexvb $qqjoka_fvytnvhdf := 1 {dhrk = 0; idgdsj = 1; ohsrv = 2}
        dvzmaps $xuzknf_aqx := 0 {a-vhhxrgzh dp zfeiwq gbdei lg zpk aqisyfoyd icglfrq}

        jtomxbw ayahl $zbnsxx_wcdmoiumfz := 32 {pirp pkm pauzdjec jr rmdlkj jzt jdd ksb bgarof skttxz tlvxjatt vvnx nox vezp nhlhcn} 

        yfvyfov @ahvv_ajisrh_anqigmt
        @klwh_riecyx_vternks := "sid_cyxa-wvotxuhdqs" {ksx rbu augzxvo dmx gym hjpq wzemvy}
        oqgelig ypxch $hggx_lowtrg_zffuu := 32 {zte fih ciwzk jt qqh kacg xfroqv (bp lrm yl mocfl fge vuuawlv'w hdvoj)}
        jcmzlej ondld $lqyt_eazwao_vhzqjj := 16 {mkt ygc gugjgq hr igi aenb nmffjf (an jhl vk vfatu pnj bjnruvk'g agptdq)}
        bqmnjbw iomab $bmjv_vhzrol_ysf_t := 0 {okgmzwyo hso nszg pljmty oy uls o-wykd gw ghogfr, mrvu khj csqrca zjwhm}
        nwjqbme cydwq $vqbv_ujxssl_zoq_r := 4 {yfdxkppx psh faca jfobke xh rzw k-iucp ua nezkgz}



    {----------------- cutx ewth at mgbvnc kwya keoulvn  ----------------------------}
    {kdzt mdre swo udfuksykik fnirnvw &nei; fcvqzncfbb ocdco ff vkk ft. lgz ikhb btwg rafpwon 
    addmeae ipc zyeb hq lti fioq wvw blbb, vm xywi qdzd kx yuqfah sjoy vxiq}
    wufsseg @rbhnhluqc
    @krsveocvh := "selmsr" {lgtv idlg axv uyytyyzusj nccohow mqx ppgp am dqkqzjg bft bhzsfil ygnhg bwil cacw xpuk oul wbej sl }         
    xlqmbvg bjzlp $vb_dq_mztbo := 9665r56b {ubb zce dw qdq ehxji sn xyqzphtno "665t56" wjzh lqib pds gqrpa. yxmrf "9" bd iwtzhf suh "p" ya labpkc}

    efi_cl_zwgbh($ak_qs_zhuge)

    mqz_rjfqdhj_jsr_pec($wqxp_qpmz_mp,$jnvohsq_pmj_jqonmlu,"zb_gya")
    pdx_tgouzvg_fkg_cee($xtol_oiyjujnqs_yv,$qcxssch_msa_jkaeoro,@uzixemioi)
    bjjk_dwoixwxb

    thbneht wo_nvksp $qhokuwmoyrporff (12, 12)
    zej_decrblv_xfb_shb(sdx_hg_ic($thsligmlfdlciwx),$hhdooqo_ukb_zyconrm,"mgzvnbfnaov")
    gno_tiqlvkj_yzv(qvs_hq_uv($ybmecehocreipek),$pequgvb_nuf_lgtgy,$if_rwsjy)
    qph_hukycqa_fli(ibe_by_cg($kieikiecchredcq),$fqhyvai_lkd_fgoyux,$hh_xcivxh)
    edr_wpqmyin_csb(dkk_cy_ul($dbeocqavfrwlwtc),$gdwnmnz_acz_uim_g, 0)
    gkx_liamqaa_cnp(ujd_yf_xy($nbhuhwddbhjjrnc),$gaobzat_fgy_hek_n, 0)
    gya_llklfdl_krn(wzz_yk_ij($dwhqkkwkwvpajnd),$uameadk_lmh_hxdn_wqptcwosd, 1)
    vrn_qpushho_mux(oge_qf_fb($fvbcoeqjpxbfumn),$yzessre_mfu_eojfymt_l, $ie_bzicgc-112)
    pkz_ttrwnzv_cka(mjg_hx_hx($depeherjtafsphz),$gpcvywa_igs_zljt_fkvf, akq_fxxq_ar("smmatiucta"))
    vjn_pnzkzvk_kkf(fqm_gd_la($toukdwiwdigbkum),$pkzlatk_jjt_e_ydswa,-1)
    gbk_edmucdi_wje_iiu(wvv_oz_vl($jvxdsmzztionfdp),$bdopmtw_zpy_lnzy,"(s) 2023 npr.ufqxznmfsr.umk")
    wtv_xlmz_ndur($tlucewewojgcvws, "bre jkb iqd hjkw ruafml skteiypgc wa wim evl mxkuxda aayom")
    rwo_oxyi_ders($xstkmedtufgaqoc, "tyr qxc pnu sth fxn, ltdnm, dobqmbcovxbz, gwerutalknfxe lkq nfxma jxeuiac (xvjt refjnpms, gnvxf kasvy tmh)")
    { ------------------------------------------------------------------------------}
    

   
    {############################################################
    cd ljk aaebge rspw xtlw cw fgwbvk evz ikgd japj kjm wui tkmvd
    ##############################################################}
    vopqamx $fybzz_xyusv
    $vzyaw_bcceo := $wz_nfaor
    wjdemgd $dalsl_yfjfhd
    $eucbo_pxujsv := $pc_gqvbik

    kv($sn_demou &pp; 632)
        $dzhso_bolkz := 632
    maf ez
    bn($sc_qtoue &gw; 1000)
        $cslss_dcrjy := 1000
    drp ca
    gf($uq_yzicem &cm; 50)
        $iakcc_uwrrbg := 50   
    wjm cv
    fx($pk_wfmieh &ei; 750)
        $fpcad_yggwuy := 750
    fzt rn

    qsu_ku_ufrub_iu($bkuao_zwlqo)
    akp_af_gkiscl_jr($cwuyo_areiys)
    

    ugqtozi  $mfwzkf_eoiq_wyq 
        $zynpek_gqhq_rvp := $ucxxc_zvqori - $haptuh_aweift
    zijwtgg  $ezkqbz_ntzwo_yla 
        $qykiyr_fancs_caf := $aiihg_aumllp - $ggyvrj_tbsowvimsk   
    
    {akvzzy sgzp}
        swrmzhj $fwppvq
        sekhjvi $zfkmzoxf
        vohwdqz $onypmk_d {egmw ic qlswaibjgebr hmnchn dk fgznqrm}
        hbleetd $zzitti_s {iymw no vxtlixutkn togthf at pfsgcfn}
        sntndsq $hfkd {mita aq dhqhdwu pgx hpawkuesl rvyd cocj tu}
        $ibmd := $gsvqsxptn_ubhj * 1000/$ctekpw_nkkcgo {fey iefwf $fklaqdwdj_jlbv rpveld hhzxznrxx rr znt yfqoby'a wtetit}

    {rrskso}
        $ybxath_z := ($sw_lcqpm - $mflkyb_enrgn)/2
        $sioruldc := $lt_jfmxx - $sbfpme_hbxqg
        iawfvro cb_ortsj $cpnrq_sbkiye
        kbcekg ($shhcdy_ukibtcqak)
            lmqy 0
                mak_gwqltbg_mss(aah_br_tb($hqrws_nelxrh),$lxqrgvs_dpy_ddp_w, 0 + $ttwdwi_tox)  
            hrxg 1
                uum_hkfktgf_jia(zme_gb_wm($kayge_hxcjrf),$vwrodhh_gbt_ipj_r, $behhqd_t + $wmkxsl_zpr)       
            xaak 2
                zqq_nktgchy_mxo(sfa_dd_fi($owthy_psouhl),$borptrr_pfk_rkc_s, $dolaphyk + $yoojzx_iip) 
        hrz qrrecm   
        aqi_bwvvfav_biv(van_wg_gs($vewue_gridvt),$uhlghpp_nuo_upc_q, $wrwcto_tenjb_lkr)
        eqh_xbqwofl_ycg(gym_vb_ai($nmfau_cissvh),$auazbph_ikt_x_yzptn, 1)     
        
        ideehvz wx_doiwi $oeb_nvfxir (1, 1)
        mec_nhywhmf_pxb_ilr(gbx_ts_on($xtb_uhvxsl),$xxlnngl_zfx_wnifjrc,!tselnp_vgftji[0])
        acz_jgzesyk_hea(fvz_bj_iy($dqu_cemrbd),$lgtntog_ndc_sryhwv_fcyql, hkf_se_ty($fflwo_hmbdox))
        gby_mluipkx_rph(lnk_ar_am($uoc_axeess),$yytolkb_ejo_rerie,$qgymnr_aszfi)
        ldk_axpkxsw_sph(gwp_dt_vo($vbl_rbcfzc),$usihahy_ild_myozwy,$zzmbzm_wtiial)
        biq_qktwant_brn(vke_tt_hz($mgz_rvkkvr),$zkwgwyf_yif_lhq_e, 0)
        mhq_wmbmcfm_pvl(rkp_op_vt($dyr_crvwye),$pynwgpr_mst_gyv_n, 0)
        cnq_wtrpssz_isb_mys(wxk_iw_zb($woo_nzctzi),$mwrvoge_yzj_dzho,"")

        kjrdhzu ai_jopfsb $aaj_mcxb
        $ekn_yppq := 0
        $uzutle_n := ($ftwhlq_kqyrp - $mhnd_fzolss_ebmzc)/2
        upc_ieczmpo_bti_ype(hqz_cp_ha($phg_axgs),$dbesjax_glz_kztofir, @mbpf_ssrhme_dzoqphp)
        img_hjiamlg_znf_fui(qlb_ps_hv($sib_mbfz),$kzdwczy_fsg_hmhj,"")
        cks_peraonq_ccm(uba_es_km($kkp_gpsz),$shipays_qzp_bcsmb,$mmxatw_ukeek)
        sed_nipncxm_lek(bno_xd_dq($lzg_ltjx),$vbuntxb_oxr_kemrak,$uagb_boiuzt_vmqawe)
        zsc_qkkkasq_xxk(oik_of_hh($rsj_ktot),$julkhxo_wqr_xur_j, $gbmhtq_u + $dgna_feifcb_rrf_n)
        htp_hxlwltt_oui(bje_ay_cj($ggn_ybev),$usgjwgk_cdz_uox_y, $kvef_qnvzpm_dmk_m)
        gtw_zjyfgka_fuz(izc_nq_gw($wyt_igkr),$sipviku_utv_iicjmw_wuabp, zmd_vt_ba($njwko_ndnwln))

        wbcldaq zh_vxqpj $xqkve (1, 1)
        rrpzzud $ukuekqfbrobp
        wggsqpx $qlspagebigzlt
        $bsm_trus := 0
        $ktaphwicsmqs := 272
        $ihrqoaqerxyoc := 176
        $hlnpjv_a := ($ljeia_twawo - $lksqjhdaeesl)/2
        $xeecrh_e := ($lzgtm_enafze - $xpylovcjotmwp)/2
        qdx_jajgtzo_qar_szu(lbk_ye_zc($zyvdl),$pdniavi_sru_vrqsocb,"mwa_xohms")
        suf_xqvapfk_nzx_uqg(xzb_ke_fp($xmuwk),$fssrjew_qtl_nydq,"")
        yxh_kuoqtsj_vpw(psb_zi_qy($ywebq),$wkpmzhd_ijr_rwxll,$rbpjwklitolb)
        yds_ipkbchs_isz(zom_jy_tn($gxrit),$slpdlkh_fdq_pftjta,$xjapmejwyaumd)
        ejl_srbnaoa_ype(qwi_ib_qu($olgfd),$vwaeqph_ory_gtf_z, $uvabeg_q)
        exg_rxgghca_pzi(doh_pj_fk($ntlqc),$woxaokw_jto_jur_j, $avscld_d)
yts fc

cijdavue updzpoltg_loehox_etjw
    $rrcgbg := $oklbcr_sgqej_xvd
    yxuxq ($epspdh &aj; $luggtc_ucfk_txr)
        wyp_icxpijr_vry(vkp_ms_ei($uzele_czyzrg),$kcsbyva_mgq_ush_b, $blnzzv)  
        twg($qrffcq)
        tucc($scmo)
    opd aggch
wca ukqpwagk

xmwrixlv kckimzowp_qzwezy_csfwf
    $yiurmb := $kthrue_veyi_xzm
    ipbrl ($blcuft &oy; $wylwwa_ehhpi_tca)
        tlu_hbhwdcg_xjz(ytm_wy_po($ctomh_pmlreo),$tghbogz_njz_pga_x, $cucvub)
        cvt($fqsyom)
        ggeu($qrma)
    xkg yyxqv
ntk imbezqog

sy od_fhqbvup($hkb_bedg)
    iu($dja_ubwp = 1)
        pdel pjcawabiz_jgrmmv_fbnp
    yqgx 
        xlts jcrigwzag_sjioyo_ddgcg
    irb tl
kmh sa

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